Interesting CSS shape navigation (chevrons)

后端 未结 2 1901
慢半拍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:

    
    

    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;
    }
    

提交回复
热议问题