I am displaying images using JavaScript code in the HTML section
element. Below is my code:
window.onload = function() {
var allImages = "";
for (var i = 0; i < 298; i++) {
var width = getRandomSize(200, 400);
var height = getRandomSize(200, 400);
allImages += '<img class="myImg"
src = "http://lorempixel.com/"+width+'/'+height+'/sports"
id = '+i+'
_id alt = "pretty kitty" > ';
}
$('#photos').append(allImages);
};
#photos {
/* Prevent vertical gaps */
line-height: 0;
-webkit-column-count: 20;
-webkit-column-gap: 0px;
-moz-column-count: 20;
-moz-column-gap: 0px;
column-count: 20;
column-gap: 0px;
}
#photos img {
width: 100% !important;
height: auto !important;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="container-fluid">
<section id="photos"></section>
</div>
By default images are getting displayed one below the another. But my question is if the image position ie. x and y coordinates are provided, can we display images on that position using HTML, CSS and JavaScript? Is there any way?