6
After many attempts I was able to turn an image into a CSS-only hexagon, I had many problems with SVG, js, etc.
However, the image is perfect in IE (incredible as it sounds) and Chrome it distorts a little, Firefox distorts a lot!
Follows code:
img {
max-width: 100%;
height: auto;
}
.hexagono {
display: inline-block;
position: relative;
width: 90px;
height: 90px;
transform: scale(1.25, .707) rotate(-45deg);
overflow: hidden;
backface-visibility: hidden;
}
.hexagono > img {
position: absolute;
transform: rotate(45deg) scale(.8, 1.404);
clip: rect(0, 120px, 200px, 2px);
}
<div class="hexagono">
<img src="http://i.imgur.com/ZNRZUaQ.png" />
</div>
Would anyone know an alternative to not blur the image?
The attributes of your CSS commented here is causing the loss of image quality, mainly the
scale
in the image. But as you can see without them the example has become an octagon instead of a hexagon, hehe.– Fernando Leal
Thanks, Fernando! I’m doing some tests... No success yet! Rs. Hugs!
– Vitor