dynamic z-index
parent
a7324b15c6
commit
6bb7f87a68
@ -1,16 +1,16 @@
|
||||
const container = document.getElementById("container");
|
||||
// console.log(container.children);
|
||||
|
||||
let images = Array.from(container.children);
|
||||
let contents = Array.from(container.children);
|
||||
// console.log(images);
|
||||
|
||||
// for (index in images) {
|
||||
// console.log(images[index]);
|
||||
// }
|
||||
|
||||
images.forEach((image) => {
|
||||
contents.forEach((item) => {
|
||||
console.log(item);
|
||||
left = Math.random() * 100;
|
||||
top = Math.random() * 100;
|
||||
image.style.left = left + "%";
|
||||
image.style.top = top + "%";
|
||||
zIndex = Math.round(Math.random() * 1000);
|
||||
|
||||
item.style.left = left + "%";
|
||||
item.style.top = top + "%";
|
||||
item.style.zIndex = zIndex;
|
||||
});
|
||||
|
Loading…
Reference in New Issue