Interesting CSS shape navigation (chevrons)

后端 未结 2 1903
慢半拍i
慢半拍i 2021-02-11 09:49

I\'m building a fairly interestingly shaped navigation for a site at the moment. The shape each menu item needs to be is illustrated below:

相关标签:
2条回答
  • 2021-02-11 10:07

    Flexbox

    You can use this example

    https://codepen.io/WBear/pen/pPYrwo

    it works on new browsers, to support old ones some changes needed.

    HTML:

    <div class="content">
    <div class="as1">
      <a href="#">NAV</a>
      </div>
     <div class="as2">
       <a href="#">NAV</a>
       </div>
      <div class="as3">
       <a href="#">NAV</a>
       </div>
      </div>
    

    CSS:

     .content {
      margin-top: 10px;
      width: 100%;
      display: inline-flex;
    
    }
    
    .as1, .as2, .as3 {
      height: 70px;
      min-width: 8%;
      max-width: 100%;
      background-color: black;
      position: relative;
      display: inline-flex;
      text-align: center;
      flex-wrap: wrap;
      flex-grow: 1;
    
    }
    
    .as1 a, .as2 a, .as3 a {
      text-decoration: none;
      display: inline-flex;
      color: white;
      margin: auto;
      font-size: 14pt;
    
    }
    
    .as1:after {
      content: "";
      position: absolute;
      right: 4px;
      border-top: 35px solid transparent;
      border-left: 25px solid black;
      border-bottom: 35px solid transparent;
      z-index: 2;
    
    }
    
    .as2 {
      background-color: grey;
      margin-left: -29px;
    
    
    }
    .as2:after {
      content: "";
      position: absolute;
      right: 4px;
      border-top: 35px solid transparent;
      border-left: 25px solid grey;
      border-bottom: 35px solid transparent;
      z-index: 3;
    
    }
    
    .as3 {
      background-color: #A9A9A9;
      margin-left: -29px;
    }
    
    0 讨论(0)
  • 2021-02-11 10:16

    Add a negative margin to each arrow:

    .navArrow {
      float: left;
      margin-left: -8px;
    }
    

    Demo: http://jsfiddle.net/S7hzu/2/

    0 讨论(0)
提交回复
热议问题