css3 - CSS draw a hexagon shaped element that stretches -
i trying draw hexagon shape in css importantly must able stretch fit content. here using image caps :
the code uses images :
#searchfield_wrapper::before { display: inline-block; content: url("../images/hexcapwhite_left.png"); position: relative; left: 6px; top: 1px; } #searchfield_wrapper::after { display: inline-block; content: url("../images/hexcapwhite_right.png"); position: relative; left: -6px; top: 1px }
but can see, doesn't quite work , hacky.
i'd love able using div elements , borders. site great shapes not stretchable : https://css-tricks.com/examples/shapesofcss/
hope can help!
:-)
a couple of pseudo elements seem work fine.
span { display: inline-block; position: relative; line-height: 1.2em; padding: 0 .5em; background: orange; margin: 2em; /* spacing */ position: relative; } span:before, span:after { content: ''; position: absolute; width: 0; height: 0; border: .6em solid transparent; /* half line-height */ } span:before { right: 100%; border-right-color: orange; } span:after { left: 100%; border-left-color: orange; }
<span>short text</span> <span>longer text</span> <span>lorem ipsum dolor sit amet.</span>
it reacts font-sizing automatically - jsfiddle
update: amended version (same basic technique - 2 pseudo-elements) using rotated boxes in order borders can added.
Comments
Post a Comment