<body><h1> Welcome to my blog</h1>
<div class="slider">
<div class="indicatorContainer">
<div id="indicator1"></div>
<div id="indicator2"></div>
<div id="indicator3"></div>
</div>
<div class="BtnContainer">
<button class="forward" onclick="setImgIndex(1)"></button>
<button class="backward" onclick="setImgIndex(-1)"></button>
</div>
<div class="backgroundimages">
<img src="https://static.pexels.com/photos/226243/pexels-photo-226243.jpeg" alt="alte Kamera">
<img src="https://static.pexels.com/photos/7882/light-bulb-light-old.jpg" alt="Glühbirne">
<img src="https://static.pexels.com/photos/85886/lamp-finger-touch-hand-85886.jpeg" alt="Finger, der auf Glühbirne zeigt">
</div>
</div></body>
h1 {
text-align: center;
text-transform: uppercase;
color: white;
padding-bottom: 10px;
font-size: 40pt;
font-weight: 100;
letter-spacing: 4pt;
}
body {
margin-bottom: 50px;
font-family: montserrat;
background: #1f1f1f;
}
.BtnContainer{
display:flex;
justify-content:space-between;
flex-flow: row nowrap;
width:100%;
}
img {
height: 500px;
width: 800px;
}
.indicatorContainer{
display:flex;
flex-direction:row;
justify-content:space-around;
position:absolute;
width:70px;
height:5px;
left:435px;
top:615px;
}
#indicator1, #indicator2, #indicator3{
border:5px solid white;
border-radius:50%;
transition: all ease-in-out 0.5s;
}
.backgroundimages {
transition: all ease-in-out 1s;
display: flex;
flex-flow: row nowrap;
justify-content: flex-start;
}
button{
border-radius:0;
}
button:hover {
cursor: pointer;
opacity: 0.8;
}
.slider {
height: 600px;
width: 800px;
overflow: hidden;
margin: auto;
}
.forward {
border: 10px solid white;
background: white
url("https://d30y9cdsu7xlg0.cloudfront.net/png/755942-200.png") no-repeat;
opacity: 0.5;
background-size: contain;
position: absolute;
top: 380px;
margin-left: 750px;
padding: 15px;
box-sizing: border-box;
transition: all 0.2s ease-in-out;
}
.backward {
overflow: hidden;
border: 10px solid #fff;
background: white
url("https://d30y9cdsu7xlg0.cloudfront.net/png/755953-200.png") no-repeat
0px;
background-size: contain;
color: none;
opacity: 0.5;
position: absolute;
top: 380px;
padding: 15px;
box-sizing: border-box;
transition: all 0.2s ease-in-out;
}
var imgIndex = 0;
var distance = -800;
var imgSelector = document.querySelector(".backgroundimages");
var indicator1Active = document.querySelector("#indicator1");
var indicator2Active = document.querySelector("#indicator2");
var indicator3Active = document.querySelector("#indicator3");
updateIndicators();
function setImgIndex(d) {
imgIndex = imgIndex + d;
if (imgIndex > 2) {
imgIndex = 0;
} else if (imgIndex < 0) {
imgIndex = 2;
}
imgSelector.style.marginLeft = distance * imgIndex + "px";
updateIndicators();
}
function updateIndicators() {
switch (imgIndex) {
case 1:
indicator1Active.style.opacity = "0.3";
indicator2Active.style.opacity = "0.8";
indicator3Active.style.opacity = "0.3";
break;
case 2:
indicator1Active.style.opacity = "0.3";
indicator2Active.style.opacity = "0.3";
indicator3Active.style.opacity = "0.8";
break;
default:
indicator1Active.style.opacity = "0.8";
indicator2Active.style.opacity = "0.3";
indicator3Active.style.opacity = "0.3";
}
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.