Add files via upload
BIN
100_projects/37-image-slider/img/1.jpg
Normal file
After Width: | Height: | Size: 391 KiB |
BIN
100_projects/37-image-slider/img/2.jpg
Normal file
After Width: | Height: | Size: 784 KiB |
BIN
100_projects/37-image-slider/img/3.jpg
Normal file
After Width: | Height: | Size: 432 KiB |
BIN
100_projects/37-image-slider/img/4.jpg
Normal file
After Width: | Height: | Size: 428 KiB |
BIN
100_projects/37-image-slider/img/5.jpg
Normal file
After Width: | Height: | Size: 523 KiB |
BIN
100_projects/37-image-slider/img/6.jpg
Normal file
After Width: | Height: | Size: 270 KiB |
BIN
100_projects/37-image-slider/img/7.jpg
Normal file
After Width: | Height: | Size: 785 KiB |
21
100_projects/37-image-slider/index.html
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Document</title>
|
||||||
|
<link rel="stylesheet" href="style.css">
|
||||||
|
<link rel="stylesheet" href="all.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="img">
|
||||||
|
<a class="btn btn-left">◀</a>
|
||||||
|
<a class="btn btn-right">▶ </a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<script src="main.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
35
100_projects/37-image-slider/main.js
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
(function () {
|
||||||
|
const pictures = [
|
||||||
|
'1',
|
||||||
|
'2',
|
||||||
|
'3',
|
||||||
|
'4',
|
||||||
|
'5',
|
||||||
|
'6',
|
||||||
|
'7'
|
||||||
|
];
|
||||||
|
|
||||||
|
const buttons = document.querySelectorAll('.btn');
|
||||||
|
const imgDiv = document.querySelector('.img');
|
||||||
|
|
||||||
|
let counter = 0
|
||||||
|
|
||||||
|
buttons.forEach(function (button) {
|
||||||
|
button.addEventListener("click", function (e) {
|
||||||
|
if (button.classList.contains('btn-left')){
|
||||||
|
counter--
|
||||||
|
if (counter < 0){
|
||||||
|
counter = pictures.length - 1
|
||||||
|
}
|
||||||
|
imgDiv.style.backgroundImage = `url('./img/${pictures[counter]}.jpg')`
|
||||||
|
}
|
||||||
|
if (button.classList.contains('btn-right')){
|
||||||
|
counter--
|
||||||
|
if (counter < 0){
|
||||||
|
counter = pictures.length - 1
|
||||||
|
}
|
||||||
|
imgDiv.style.backgroundImage = `url('./img/${pictures[counter]}.jpg')`
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}) ();
|
1
100_projects/37-image-slider/note.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
https://www.youtube.com/watch?v=sxq-https://www.youtube.com/watch?v=sxq-8qv2i1Q&list=PL9bD98LkBR7P16BndaNtP4x6Wf5Ib85Hm&index=7&ab_channel=Tech2etc
|
44
100_projects/37-image-slider/style.css
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
*{
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
body{
|
||||||
|
background:linear-gradient(to right, #D4D3DD, #EFEFBB);
|
||||||
|
}
|
||||||
|
.img{
|
||||||
|
width: 60%;
|
||||||
|
height: 80vh;
|
||||||
|
background-image: url("./img/1.jpg");
|
||||||
|
background-position: center;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-size: cover;
|
||||||
|
position: relative;
|
||||||
|
margin: 30px auto;
|
||||||
|
}
|
||||||
|
.btn-left{
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 0;
|
||||||
|
color: #fff;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
font-size: 1.5rem;
|
||||||
|
padding: 15px;
|
||||||
|
border-radius: 11px;
|
||||||
|
text-align: center;
|
||||||
|
backdrop-filter: blur(5px);
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.btn-right{
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
right:-35px;
|
||||||
|
color: #fff;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
font-size: 1.5rem;
|
||||||
|
padding: 15px;
|
||||||
|
border-radius: 11px;
|
||||||
|
text-align: center;
|
||||||
|
backdrop-filter: blur(5px);
|
||||||
|
cursor: pointer;
|
||||||
|
}
|