I am trying to create a vertical mosaic style representation of a series of images. The final piece consists of 55 photos, all of the same view and shot throughout a day. I have achieved the desired result, however, the code is clunky and inefficient.
I am looking for improvements to my approach so that:
- The size of the image slices are generated programmatically
- The mosaic is centered horizontally on the page
My current approach uses the following HTML and CSS:
<div class='mainImage crop-01'>
<img src="../2019-08-15/02.jpg" alt="">
</div>
<div class="mainImage crop-02">
<img src="../2019-08-15/03.jpg" alt="">
</div>
<div class="mainImage crop-03">
<img src="../2019-08-15/04.jpg" alt="">
</div>
<div class="mainImage crop-04">
<img src="../2019-08-15/05.jpg" alt="">
</div>
<div class='mainImage crop-05'>
<img src="../2019-08-15/06.jpg" alt="">
</div>
<div class="mainImage crop-06">
<img src="../2019-08-15/07.jpg" alt="">
</div>
<div class="mainImage crop-07">
<img src="../2019-08-15/08.jpg" alt="">
</div>
<div class="mainImage crop-08">
<img src="../2019-08-15/09.jpg" alt="">
</div>
.mainImage {
height: 775px;
position: absolute;
top: 0;
border: 2px solid crimson;
}
.mainImage img {
height: 100%;
}
.crop-01 {
left: 10px;
width: 150px;
overflow: hidden;
text-indent: 0px;
}
.crop-02 {
left: 160px;
width: 150px;
overflow: hidden;
text-indent: -150px;
}
.crop-03 {
left: 310px;
width: 150px;
overflow: hidden;
text-indent: -300px;
}
.crop-04 {
left: 460px;
width: 150px;
overflow: hidden;
text-indent: -450px;
}
.crop-05 {
left: 610px;
width: 150px;
overflow: hidden;
text-indent: -600px;
}
.crop-06 {
left: 760px;
width: 150px;
overflow: hidden;
text-indent: -750px;
}
.crop-07 {
left: 910px;
width: 150px;
overflow: hidden;
text-indent: -900px;
}
.crop-08 {
left: 1060px;
width: 150px;
overflow: hidden;
text-indent: -1050px;
}
I am looking for a more efficient approach to creating a vertical mosaic-style representation of a series of images. The final piece consists of 55 photos, all of the same view and shot throughout a day. The desired results are:
- Image slices are generated programmatically
- The mosaic is centered horizontally on the page
If you have any suggestions, please let me know.