Chevron Buttons

I am looking for this with CSS:

enter image description here

and this is what I have:

.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> 

Questions:

  • It is not possible to correctly display the correct side borders.
  • It is impossible to get the correct border of the last element to be normal (and not a chevron).
  • It is not possible to obtain a hover state due to correct lateral boundaries.
+5
source share
3 answers

I think this code is useful.

 .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> 
+1
source

Here 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> 

Hope this helps you :)

+3
source

 *{ margin: 0; padding: 0; } .container{ margin: 20px; display: flex; flex-direction: row; border: 1px solid skyblue; width: 200px; overflow: hidden; } .left,.right{ display: inline-block; //border: 1px solid black; line-height: 50px; width: 100px; height: 100%; position: relative; } .right{ text-align: center; } p:hover{ background-color: skyblue; color: white; } .left::after{ content:''; position: absolute; left: 70px; top: 3px; display: inline-block; width: 45px; height: 45px; z-index: 2; background:white; transform:rotate(-45deg); border-right: 1px solid skyblue; border-bottom: 1px solid skyblue; } .left:hover::after{ background-color: skyblue; } 
 <div class="container"> <p class="left">LEFT</p> <p class="right">RIGHT</p> </div> 

He is doing his best.

I hope this will be helpful to you.

0
source

Source: https://habr.com/ru/post/1271219/


All Articles