Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chevron buttons

Tags:

html

css

I'm looking to achieve this with CSS:

enter image description here

and this is what I've got:

.breadcrumb {
  list-style: none;
  overflow: hidden;
  font: 18px Helvetica, Arial, Sans-Serif;
  margin: 0;
  padding: 0;
}

.breadcrumb li {
  float: left;
}

.breadcrumb li a {
  border: 1px solid #c00;
  color: black;
  text-decoration: none;
  padding: 10px 0 10px 55px;
  background: #fff;
  position: relative;
  display: block;
  float: left;
}

.breadcrumb li a:after {
  content: " ";
  display: block;
  width: 0;
  height: 0;
  border-top: 50px solid transparent;
  /* Go big on the size, and let overflow hide */
  border-bottom: 50px solid transparent;
  border-left: 30px solid #fff;
  position: absolute;
  top: 50%;
  margin-top: -50px;
  left: 100%;
  z-index: 2;
}

.breadcrumb li a:before {
  content: " ";
  display: block;
  width: 0;
  height: 0;
  border-top: 50px solid transparent;
  /* Go big on the size, and let overflow hide */
  border-bottom: 50px solid transparent;
  border-left: 30px solid red;
  position: absolute;
  top: 50%;
  margin-top: -50px;
  margin-left: 1px;
  left: 100%;
  z-index: 1;
}

.breadcrumb li:first-child a {
  padding-left: 10px;
}

.breadcrumb li a:hover {
  background: hsla(34, 85%, 25%, 1);
}

.breadcrumb li a:hover:after {
  border-left-color: hsla(34, 85%, 25%, 1) !important;
}

.breadcrumb li:last-child a {
  border-right: 1px solid red;
}

.breadcrumb li:last-child a:before {
  border-left: 0 solid transparent;
}
<ul class="breadcrumb">
  <li><a href="#">Home</a></li>
  <li><a href="#">Vehicles</a></li>
</ul>

Issues:

  1. Can't get the right side borders to show correctly
  2. Can't get the right border of last element to be normal (not a chevron)
  3. Can't get hover state right because of right side borders.
like image 790
eozzy Avatar asked Aug 25 '17 06:08

eozzy


2 Answers

Here's is my working jsFiddle

    .breadcrumb {
  list-style: none;
  overflow: hidden;
  font: 18px Helvetica, Arial, Sans-Serif;
  margin: 0;
  padding: 0;
}

.breadcrumb li {
  float: left;
  position: relative;
  background: #fff;
  margin: 0 5px;
}

.breadcrumb li a {
  border: 1px solid #0976a1;
  color: #0976a1;
  text-decoration: none;
  padding: 10px 10px 10px 32px;
  position: relative;
  display: block;
  z-index: 99;
  font-weight: bold;
}
.breadcrumb li:first-child a {
  padding-left: 10px;
  border-right: none;
}

.breadcrumb li:last-child a {
 border-left: none;
}
.breadcrumb li:before, .breadcrumb li:after{
  content: " "; 
  display: block; 
  width: 33px; 
  height: 29px; 
  border-top: 5px solid transparent; 
  border-bottom: 1px solid #0976a1; 
  border-right: 1px solid #0976a1; 
  position: absolute; 
  top: 4px; 
  z-index: -1;
  background: #fff;
  transform: rotate(-45deg);
  -moz-transform: rotate(-45deg);

}
.breadcrumb li:before {
  left: 87%; 
}
.breadcrumb li:after {
  left: 81%;
}
.breadcrumb li:first-child:before, .breadcrumb li:first-child:after{ z-index: 1; }
.breadcrumb li:first-child:after{ left: 73%; }
.breadcrumb li:last-child:before, .breadcrumb li:last-child:after{
  display: none;
}


.breadcrumb li:first-child:hover:after, .breadcrumb li:hover{ background: #0976a1; }
.breadcrumb li:hover a{ border-color: transparent; }
.breadcrumb li:hover a{ color: #fff; }
<ul class="breadcrumb">
  <li><a href="#">Home</a></li>
  <li><a href="#">Vehicles</a></li>
</ul>

I hope this will help you :)

like image 200
bellabelle Avatar answered Sep 30 '22 06:09

bellabelle


I think this code is helpful.

.breadcrumb {
  list-style: none;
  overflow: hidden;
  font: 18px Helvetica, Arial, Sans-Serif;
  margin: 0;
  padding: 0;
}

.breadcrumb li {
  float: left;
  margin-right: 10px;
}
.breadcrumb li:first-child {
  z-index: 9;
  position:relative;
}
.breadcrumb li a {
  border: 1px solid #006A9C;
  color: black;
  text-decoration: none;
  padding: 10px 10px 10px 10px;
  background: #fff;
  position: relative;
  display: block;
  float: left;
}
.breadcrumb li:first-child a:after {
  border-color:#fff;
  border-style: solid;
  border-width: 15px;
  bottom: -30px;
  box-shadow: 0 0 0 0 #c00, -1px 1px 0 1px #006A9C;
  content: "";
  height: 0;
  position: absolute;
  right: -29px;
  transform: rotate(-135deg);
  transform-origin: 0 0 0;
  width: 0;
  z-index: -1;
}

.breadcrumb li:first-child a {
  border-right: 0;
}
.breadcrumb li:last-child a {
  border-left: 0;
}
.breadcrumb li:last-child a:after{
  display:none;
}
.breadcrumb li:last-child a:before{
  border-color:#fff;
  border-style: solid;
  border-width: 15px;
  bottom: -30px;
  box-shadow: 0 0 0 0 #006A9C, -1px 1px 0 1px #006A9C;
  content: "";
  height: 0;
  position: absolute;
  left: -1px;
  transform: rotate(-135deg);
  transform-origin: 0 0 0;
  width: 0;  
}
.breadcrumb li:last-child a {
  padding-left: 28px;
}
.breadcrumb li a:hover {
  background: #006A9C;
  color: #fff;
}
.breadcrumb li a:first-child:hover::after {
  border-color:#006A9C;
}
<ul class="breadcrumb">
  <li><a href="#">Home</a></li>
  <li><a href="#">Vehicles</a></li>
</ul>
like image 39
ankita patel Avatar answered Sep 30 '22 07:09

ankita patel