Responsive Image Grid using SVG wrappers

Developer
Size
3,859 Kb
Views
72,864

How do I make an responsive image grid using svg wrappers?

The images center horizontally & vertically within the SVG viewbox. Any image aspect ratio is supported. Odd images at the end are horizontally centered if you want them to be. Last image is included as a data URI to show that's possible also. Best tested full screen. . What is a responsive image grid using svg wrappers? How do you make a responsive image grid using svg wrappers? This script and codes were developed by Noah Blon on 24 June 2022, Friday.

Responsive Image Grid using SVG wrappers Previews

Responsive Image Grid using SVG wrappers - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Responsive Image Grid using SVG wrappers</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="wrap">
<svg xmlns="http://www.w3.org/2000/svg" > <image width="100%" height="100%" xlink:href="http://placehold.it/300x300" />
</svg>
<svg> <image width="100%" height="100%" xlink:href="http://placehold.it/300x150" />
</svg>
<svg> <image width="100%" height="100%" xlink:href="http://placehold.it/150x300" />
</svg>
<svg> <image width="100%" height="100%" xlink:href="http://placehold.it/1000x1000" />
</svg>
<svg> <image width="100%" height="100%" xlink:href="http://placehold.it/300x1000" />
</svg>
<svg> <image width="100%" height="100%" xlink:href="http://placehold.it/1000x300" />
</svg>
<svg> <image width="100%" height="100%" xlink:href="http://placehold.it/150x1000" />
</svg>
<svg> <image width="100%" height="100%" xlink:href="http://placehold.it/1000x150" />
</svg>
<svg> <image width="100%" height="100%" xlink:href="http://placehold.it/300x300" />
</svg>
<svg> <image width="100%" height="100%" xlink:href="http://placehold.it/300x300" />
</svg>
<svg> <image width="100%" height="100%" xlink:href="http://placehold.it/300x300" />
</svg>
<svg> <image width="100%" height="100%" xlink:href="http://placehold.it/300x300" />
</svg>
<svg> <image width="100%" height="100%" xlink:href="data:image/gif;base64,R0lGODdhLAEsAeMAAMzMzJaWlsXFxaqqqpycnKOjo76+vre3t7GxsQAAAAAAAAAAAAAAAAAAAA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ALe8iNVqjqixJl91lbp3HgeJ1Uvvrwe2K292b+3by6oSpOescLudSbCkFmAVXoGpWgAweaE1eLCivSmaS2aYBuAdadBFPJljHaeGQchwgepdwpHByKh4lYUcqnk+efayLslONfNfWfo1mIEnN9jiYBrUzOa5O9t0Ms5Z9ZyL0Apy5ZaY8D3Ngc3yWkwB01ZJ7fRYUPNSlIOW+hVUU0gJpbTP19K1wdcFhC3d2EqNDPfZMdVt991456333nz37fffgAcu+OCEF2744YgnrvjijDfu+OOQRy755JRXbvnlaZhnrvnmnHfu+eeghy766KSXbvrpqKeu+uqst+7667DHLvvstNdu++2456777rz37vvvwAcv/PDEF2/88cgnr/zyzDfv/PPQRy/99NRXb/312Gev/fbcd+/99+CHL/745Jdv/vnopz9MBAA7" />
</svg>
</div>
<div class="meta"> <span>Responsive Image Grid using SVG Wrappers</span><br/>
</div> <script src="js/index.js"></script>
</body>
</html>

Responsive Image Grid using SVG wrappers - Script Codes CSS Codes

* { box-sizing: border-box;
}
body { width: 100%; height: 100%; background: url(http://subtlepatterns.com/patterns/grey.png);
}
.wrap{ background: hsla(60, 70%, 40%, .1); /*Centers photos */ text-align: center; /*Kills inline-block white-space: http://codepen.io/chriscoyier/pen/hmlqF*/ font-size: 0px;
}
svg{ display: inline-block; padding: 1%; width: 100%; /* Add a border to see the svg viewbox */ /*border: 1px dotted black;*/
}
/*Media Queries - Width*/
@media all and (min-width: 27em) { svg{ width: 50%; }
}
@media all and (min-width: 40em) { svg{ width: 33.33%; }
}
@media all and (min-width: 60em) { svg { width: 25%; }
}
/*Media Queries - Height*/
@media all and (min-height: 40em) { svg { height: 50%; }
}
@media all and (min-height: 65em) { svg { height: 25% }
}
/* title box */
.meta{ width: 150px; font-family: Helvetica, Arial, sans-serif; background: hsla(0,0%,0%, .5); position: fixed; top: 5px; right: 5px; color: white; padding: 5px; text-align: center; font-size:.8em;
}
.meta a{ color: lightBlue;
}

Responsive Image Grid using SVG wrappers - Script Codes JS Codes

/*
Responsive Image Grid using SVG wrappers
Full Screen: http://codepen.io/noahblon/full/stnjd
The image centers horizontally & vertically within the SVG viewbox. Any image aspect ratio is supported. Vertical media queries too. Odd images at the end will center horizontally. Last image is included as a data URI to show that's possible too. Best tested full screen: http://codepen.io/noahblon/full/stnjd
*/
Responsive Image Grid using SVG wrappers - Script Codes
Responsive Image Grid using SVG wrappers - Script Codes
Home Page Home
Developer Noah Blon
Username noahblon
Uploaded June 24, 2022
Rating 4
Size 3,859 Kb
Views 72,864
Do you need developer help for Responsive Image Grid using SVG wrappers?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Noah Blon (noahblon) Script Codes
Create amazing blog posts with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!