Key features
- Pixel perfect seamless mosaics
- Obviously responsive
- Create mosaics of images or divs containing whatever your want
- Automatically loads high resolution images for retina glory
<html>
<head>
...
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script type="text/javascript" src="jquery.mosaic.js"></script>
<link rel="stylesheet" type="text/css" href="jquery.mosaic.css" />
...
</head>
<body>
...
<div id="myMosaic">
<img src="image1.jpg" width="400" height="350" />
<img src="image2.jpg" width="320" height="200" />
<img src="image3.jpg" width="870" height="420" />
<img src="image4.jpg" width="442" height="922" />
...
</div>
<script>
$('#myMosaic').Mosaic();
</script>
You can optionally specify the following options when calling the plugin to customize the mosaic:
For example:
<div id="myMosaic">
<img src="image1.jpg" />
<img src="image2.jpg" />
<img src="image3.jpg" />
<img src="image4.jpg" />
...
</div>
$('#myMosaic').Mosaic({
maxRowHeight: 800,
refitOnResize: true,
refitOnResizeDelay: false,
defaultAspectRatio: 0.5,
maxRowHeightPolicy: 'crop',
highResImagesWidthThreshold: 850,
responsiveWidthThreshold: 500
});
<div id="myMosaic" data-max-row-height="800" data-refit-on-resize="1" data-refit-on-resize-relay="0" data-default-aspect-ratio="0.5" data-max-row-height-policy="crop" data-high-res-images-width-threshold="850" data-responsive-width-threshold="500">
<img src="image1.jpg" />
<img src="image2.jpg" />
<img src="image3.jpg" />
<img src="image4.jpg" />
...
</div>
$('#myMosaic').Mosaic();
<div id="myMosaic">
<img src="image1.jpg" data-aspect-ratio="1.432" />
<img src="image2.jpg" data-aspect-ratio="0.3" />
<img src="image3.jpg" data-aspect-ratio="1.4842" />
<img src="image4.jpg" data-aspect-ratio="0.883" />
...
</div>
<div id="myMosaic">
<img src="image1.jpg" data-aspect-ratio="1.432" data-high-res-image-src="image1_highres.jpg"/>
<img src="image2.jpg" data-aspect-ratio="0.3" data-high-res-image-src="image2_highres.jpg" />
<img src="image3.jpg" data-aspect-ratio="1.4842" data-high-res-image-src="image3_highres.jpg" />
<img src="image4.jpg" data-aspect-ratio="0.883" data-high-res-image-src="image4_highres.jpg" />
...
</div>
<div id="myMosaic">
<div data-aspect-ratio="1.32">My content</div>
<div data-aspect-ratio="1.02">My content</div>
<div data-aspect-ratio="0.8">My content</div>
<div data-aspect-ratio="1.02">My content</div>
...
</div>
<div id="myMosaic">
<div class="item withImage" data-aspect-ratio="1.32" style="background-image: url('image1.jpg');">My content</div>
<div class="item withImage" data-aspect-ratio="1.02" style="background-image: url('image2.jpg');">My content</div>
<div class="item withImage" data-aspect-ratio="0.8" style="background-image: url('image3.jpg');">My content</div>
<div class="item withImage" data-aspect-ratio="1.02" style="background-image: url('image4.jpg');">My content</div>
...
</div>
<div id="myMosaic">
<div class="item withImage" data-aspect-ratio="1.32" style="background-image: url('image1.jpg');" data-high-res-background-image-url="image1_highres.jpg">My content</div>
<div class="item withImage" data-aspect-ratio="1.02" style="background-image: url('image2.jpg');" data-high-res-background-image-url="image2_highres.jpg">My content</div>
<div class="item withImage" data-aspect-ratio="0.8" style="background-image: url('image3.jpg');" data-high-res-background-image-url="image3_highres.jpg">My content</div>
<div class="item withImage" data-aspect-ratio="1.02" style="background-image: url('image4.jpg');" data-high-res-background-image-url="image4_highres.jpg">My content</div>
...
</div>
<div id="myMosaic">
<div class="item withImage" data-aspect-ratio="1.32" style="background-image: url('image1.jpg');" data-high-res-background-image-url="image1_highres.jpg">
<div class="overlay"><div class="texts">
<h1>Title</h1>
<h1>Subtitle</h1>
</div></div>
</div>
<div class="item withImage" data-aspect-ratio="1.02" style="background-image: url('image2.jpg');" data-high-res-background-image-url="image2_highres.jpg">
<div class="overlay"><div class="texts">
<h1>Title</h1>
<h1>Subtitle</h1>
</div></div>
</div>
<div class="item withImage" data-aspect-ratio="0.8" style="background-image: url('image3.jpg');" data-high-res-background-image-url="image3_highres.jpg">
<div class="overlay"><div class="texts">
<h1>Title</h1>
<h1>Subtitle</h1>
</div></div>
</div>
..
</div>