diff --git a/100_projects/28-show-random-image-every-x-second/css.css b/100_projects/28-show-random-image-every-x-second/css.css new file mode 100644 index 0000000..ceb88ad --- /dev/null +++ b/100_projects/28-show-random-image-every-x-second/css.css @@ -0,0 +1,40 @@ +*{ + box-sizing: border-box; + margin: 0; + padding: 0; +} +body{ + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + height: 100vh; + position: relative; + background: linear-gradient(to bottom right, #2389da, #74ccf4, #5abcd8); +} +#myImg{ + position: relative; + width: 800px; + height: 450px; + box-shadow: 10px 10px 5px rgba(0,0,0, .4); + transition: .3s; +} +body::before{ + content: ''; + width: calc(800px - 30px); + height: calc(450px - 30px); + border: 3px solid #e0ffff; + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + z-index: 9999; +} +@media(max-width:767px){ + #myImg{ + width: 300px; + } + body::before{ + width: calc(300px - 30px); + } +} \ No newline at end of file diff --git a/100_projects/28-show-random-image-every-x-second/imgs/01.jpg b/100_projects/28-show-random-image-every-x-second/imgs/01.jpg new file mode 100644 index 0000000..fedca77 Binary files /dev/null and b/100_projects/28-show-random-image-every-x-second/imgs/01.jpg differ diff --git a/100_projects/28-show-random-image-every-x-second/imgs/02.jpg b/100_projects/28-show-random-image-every-x-second/imgs/02.jpg new file mode 100644 index 0000000..ef969e1 Binary files /dev/null and b/100_projects/28-show-random-image-every-x-second/imgs/02.jpg differ diff --git a/100_projects/28-show-random-image-every-x-second/imgs/03.jpg b/100_projects/28-show-random-image-every-x-second/imgs/03.jpg new file mode 100644 index 0000000..3a8c78b Binary files /dev/null and b/100_projects/28-show-random-image-every-x-second/imgs/03.jpg differ diff --git a/100_projects/28-show-random-image-every-x-second/imgs/04.jpg b/100_projects/28-show-random-image-every-x-second/imgs/04.jpg new file mode 100644 index 0000000..962c7cd Binary files /dev/null and b/100_projects/28-show-random-image-every-x-second/imgs/04.jpg differ diff --git a/100_projects/28-show-random-image-every-x-second/imgs/05.jpg b/100_projects/28-show-random-image-every-x-second/imgs/05.jpg new file mode 100644 index 0000000..f3f7b41 Binary files /dev/null and b/100_projects/28-show-random-image-every-x-second/imgs/05.jpg differ diff --git a/100_projects/28-show-random-image-every-x-second/imgs/06.jpg b/100_projects/28-show-random-image-every-x-second/imgs/06.jpg new file mode 100644 index 0000000..8157525 Binary files /dev/null and b/100_projects/28-show-random-image-every-x-second/imgs/06.jpg differ diff --git a/100_projects/28-show-random-image-every-x-second/imgs/07.jpg b/100_projects/28-show-random-image-every-x-second/imgs/07.jpg new file mode 100644 index 0000000..8e5b4d7 Binary files /dev/null and b/100_projects/28-show-random-image-every-x-second/imgs/07.jpg differ diff --git a/100_projects/28-show-random-image-every-x-second/imgs/08.jpg b/100_projects/28-show-random-image-every-x-second/imgs/08.jpg new file mode 100644 index 0000000..881aca2 Binary files /dev/null and b/100_projects/28-show-random-image-every-x-second/imgs/08.jpg differ diff --git a/100_projects/28-show-random-image-every-x-second/index.html b/100_projects/28-show-random-image-every-x-second/index.html new file mode 100644 index 0000000..68234da --- /dev/null +++ b/100_projects/28-show-random-image-every-x-second/index.html @@ -0,0 +1,15 @@ + + + + + + + Document + + + + + + + + diff --git a/100_projects/28-show-random-image-every-x-second/main.js b/100_projects/28-show-random-image-every-x-second/main.js new file mode 100644 index 0000000..43119d0 --- /dev/null +++ b/100_projects/28-show-random-image-every-x-second/main.js @@ -0,0 +1,21 @@ +var myElement = document.getElementById('myImg'), + myImgs = [ + 'imgs/01.jpg', + 'imgs/02.jpg', + 'imgs/03.jpg', + 'imgs/04.jpg', + 'imgs/05.jpg', + 'imgs/06.jpg', + 'imgs/07.jpg', + 'imgs/08.jpg' + ]; +function changeImage(myElement, myImgs){ + 'use strict'; + setInterval(function () { + + var myRandomNum = Math.floor(Math.random() * myImgs.length); + console.log(myRandomNum) + myElement.src = myImgs[myRandomNum]; + }, 1000); +} +changeImage(myElement, myImgs); \ No newline at end of file