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/
you can use
vertical-padding
in%
+ pseudo element to draw a square to begin with.Then , use a second element to draw a mask.
DEMO
HTML
CSS
You can create an image with transparent hexagon shape and superimpose it over injected image.
HTML:
CSS:
Demo: http://jsfiddle.net/dr6Hp/3/
Here is the demo and the repositery for the responsive grid of hexagons. The code here isn't maintained. It was moved to github and improved so comments, issue reporting and contributions should be made there.
This technique uses :
<img>
tag<li>
tag and an<a>
tagoverflow:hidden;
nth-child()
to space the hexagons in a regular patternAnd more to create the hexagon grid with the
<img>
tag.Hexagon grid features :
Full code
The following snippet isn't the latest version of the grid. The GitHub repo is maintained and up to date. Issues and contributions can be made there.
Changing the number of hexagons per row
The grid adapts the number of hexagons per row according to the viewport width from 5 on screens wider than 1200px to 2 on screens narrower than 600px.
If you don't need the media queries but just want to change the number of hexagons per row, you can keep the CSS from the corresponding media query and remove the unneeded ones.
For more customization, see sizing and spacing of hexagons.
Demos
For a list of all the demos, see this codepen collection: Responsive grids of hexagons with different numbers of hexagons per row, centering options and more...
Here is the original codepen demo with the
.pusher
element to make an irregular grid of hexagons. The.pusher
element is used to make the "holes" in the grid with empty hexagons.Check out this responsive hexagonal grid that is implemented with AngularJS.
HTML
CSS: The hexagonal grid
CSS: The animation
AngularJS
Original: http://rachidmrad.com/
All the credit goes to Mr. Rachid Mrad, he is an awesome web designer.
https://github.com/mnishiguchi/hexagonal_grid
if it is about honeycombing, here is a CSS possibilitie. http://codepen.io/gc-nomade/pen/eyntg/
instead of using class in img tag use css in container img like
it will save you a lot trouble of putting class in images