Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

full width responsive arrow on bottom of div

Tags:

css

css-shapes

Hee!

Currently I'm trying to make the following nav

nav

but ending up getting the following

enter image description here

How can I lower the height of the arrow I'm adding at the bottom but keeping the full width?

nav {
  position: relative;
  display: inline-block;
  height: 50px;
  width: 100%;
  text-align: center;
  color: white;
  background: gray;
  line-height: 50px;
  text-decoration: none;
  padding-bottom: 15%;
  background-clip: content-box;
  overflow: hidden;
}
nav:after {
  content: "";
  position: absolute;
  top: 50px;
  left: 0;
  background-color: inherit;
  padding-bottom: 50%;
  width: 57.7%;
  z-index: -1;
  -webkit-transform-origin: 0 0;
  -ms-transform-origin: 0 0;
  transform-origin: 0 0;
  -webkit-transform: rotate(-30deg) skewX(30deg);
  -ms-transform: rotate(-30deg) skewX(30deg);
  transform: rotate(-30deg) skewX(30deg);
}
<nav>nav</nav>

http://jsfiddle.net/v50wwuw6/

like image 294
Ivo Avatar asked Sep 11 '25 18:09

Ivo


1 Answers

Using the border triangle technique with vw unit: http://jsfiddle.net/hamop5ca/

30px is the arrow height.

nav {
    position: relative;
    height: 50px;
    width:100%;
    background: gray;
}
nav:before {
  content: "";
  position: absolute;
  top: 100%;
  left: 0;
  border-top: 30px solid red;
  border-left: 50vw solid transparent;
  border-right: 50vw solid transparent;
}


<nav>nav</nav>
like image 125
Michael Avatar answered Sep 14 '25 23:09

Michael