I loaded in multiple images on my website from the internet. Is it possible to give all those images an hexagon shape in a responsive grid?
<div>
<img src="link" class="Image">
</div>
<div>
<img src="link" class="Image">
</div>
...
I found multiple ways to do this but you needed to fill in the image src
in the CSS code.
This isnt possible for me cause the website loads in random images from the internet with jQuery so I can't use background images.
I tried this: http://jsfiddle.net/8f5m5wv0/
Alright, here's a clean, cross-browser compatible solution that will even allow you to honeycomb the hexagons:
For this to work, you need to wrap each image in 2 containers, since one will be used for the top left / bottom right cut-off and the other for the top right / bottom left cut-off.
The CSS then gives each cut-off container a
skew
that adds the angles to the image:Demo: http://jsfiddle.net/XkQtF/3/
Note: to improve the render quality, I'd advise to give both
.outerclip
and.innerclip
the same fixed height.To get the honeycombs, you can put several images in a
row
container and then offset each odd row by a couple of pixels like this:Demo: http://jsfiddle.net/XkQtF/4/
TRY THIS FIDDLE
http://jsfiddle.net/ku860uoh/
CSS
Demo
HTML:
SASS (with Compass):
Then, if you want to place an image in the hexagon, inside
.contents
useand, for example, style it like this: