Slider
Slider
</div>
</div>
body{
display: flex;
justify-content: center;
}
.slide{
position: relative;
display: block;
width: 800px;
}
.slide img{
width: 100%;
height: 500px;
}
.slide h2{
position: absolute;
bottom: 15px;
right: 0;
left:0;
text-align: center;
}
.slider-wrapper{
position: relative;
}
.arrow{
z-index: 1;
position: absolute;
top:50%;
transform: translateY(-50%);
width: 50px;
height: 50px;
font-size:1.2rem;
background: white;
cursor: pointer;
}
.arrow-right{
right: 0;
}
.dots{
display: flex;
justify-content: center;
position: absolute;
bottom: 10px;
left:0;
right: 0;
}
.dots .dot{
width: 20px;
height: 20px;
background: black;
margin: 0 5px;
border-radius: 15px;
cursor: pointer;
}
.dot.active{
background: green;
}
let imgData = [
{
id:1,
imgUrl:"bichebi.jpg",
title:"bichoba",
url:"google.com",
},
{
id:2,
imgUrl:"monke.jpg",
title:"monke",
url:"google.com",
},
{
id:3,
imgUrl:"praktikuli.png",
title:"prakqitukuilo",
url:"google.com",
}
]
let sliderIndex = 0;
// წერტილების შექმნა
let createDots = ()=>{
let dotsDiv = document.createElement("div");
dotsDiv.classList.add("dots");
imgData.forEach((element)=>{
let dot = document.createElement("div");
dot.classList.add("dot");
dot.setAttribute("data-id",element.id-1);
dotsDiv.appendChild(dot);
dot.addEventListener("click",(item)=>{
sliderIndex = item.target.getAttribute("data-id");
CreateSlider();
})
})
return dotsDiv;
}
CreateSlider();