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?
instead of using class in img tag use css in container img like
.container img{ your code}
it will save you a lot trouble of putting class in images
if it is about honeycombing, here is a CSS possibilitie. http://codepen.io/gc-nomade/pen/eyntg/
<div><!-- even div gets a negative bottom margin. all of them gets a negative right margin -->
<span><!-- skewed and rotated -->
<img src="http://lorempixel.com/200/200/food/1"/><!-- rotated back, unskewed and rescaled -->
</span>
</div>
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.
<div class="outerclip">
<div class="innerclip">
<img src="http://img1.wikia.nocookie.net/__cb20090714124528/firefly/images/thumb/1/11/Firefly_class_ship.jpg/100px-136,568,0,431-Firefly_class_ship.jpg" />
</div>
</div>
The CSS then gives each cut-off container a skew
that adds the angles to the image:
.outerclip {
-webkit-transform: skew(-30deg);
-ms-transform: skew(-30deg);
-transform: skew(-30deg);
overflow: hidden;
display: inline-block;
}
.innerclip {
-webkit-transform: skew(50deg);
-ms-transform: skew(50deg);
transform: skew(50deg);
overflow: hidden;
display: inline-block;
}
img {
-webkit-transform: skew(-30deg);
-ms-transform: skew(-30deg);
transform: skew(-30deg);
}
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/