css - CSS3 hexagonal button with border and rounded corners -


i have image , has odd shape : flat hexagon borders , rounded corners. make css.
have tried make css can expand dynamicaly longer text not working me.

here image

hexagonal button rounded corners , border

css :

you can achieve shape 2 3d transformed pseudo elements :

div {    display: inline-block;    position: relative;    padding: 20px 50px;    perspective: 30px;  }  div:after,div:before {    content: '';    position: absolute;    top: 0;    width: 100%; height: 100%;    z-index: -1;    background: orange;    border: 2px solid darkorange;    box-sizing: border-box;  }  div:before {    right: 50%;    transform-origin: 100% 0;    transform: rotatey(-10deg);    border-radius: 10px 0 0 10px;    border-width: 3px 0 3px 5px;  }  div:after {    left: 50%;    transform-origin: 0 0;    transform: rotatey(10deg);    border-radius: 0 10px 10px 0;    border-width: 3px 5px 3px 0;  }  body{text-align:center;}
<div>some text</div><br/><br/>  <div>some longer text</div>

note need add appropriate vendor prefixes maximize browser support. see caniuse more information.


svg :

another alternative use inline svg polygon element :

div{      display:inline-block;      position:relative;      padding:20px 50px;  }  svg{      position:absolute;      top:0; left:0;      z-index:-1;      min-width:100%; min-height:100%;  }
<div class="btn">      text      <svg viewbox="0 0 100 30">          <polygon points="2 8 50 2 98 8 98 22 50 28 2 22" stroke-linejoin="round" stroke-width="2" stroke="darkorange" fill="orange" />      </svg>  </div>  <div class="btn">      longer text      <svg viewbox="0 0 100 30">          <polygon points="2 8 50 2 98 8 98 22 50 28 2 22" stroke-linejoin="round" stroke-width="2" stroke="darkorange" fill="orange" />      </svg>  </div>


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -