2
onload = start;
function start(){
var i = 1;
function Move(){
i = (i%3)+1; // 4 is the Number of image in slider
document.getElementById('t'+i).checked = true;
}
setInterval(Move,3000); //change img in 3 sec
}
body{ background-color:#0066FF;}
.ct{
position:relative;
width:400px;
height:220px;
margin:auto;
border:2px solid #000;
overflow:hidden;
}
input{ display:none;}
.img_s{ position:absolute;
width:100%;
height:100%;
z-index:-1;
font-size:25px;
text-align:center;
}
.im1, .im2, .im3{ position:relative; width:400px;
height:225px;
}
.pre, .nxt{ position:absolute;
width:12%;
height:100%;
top:0;
background:rgba(88,88,88,.4);
z-index:99;
cursor:pointer;
font-size:30px;
}
p{ position:relative; top:50px;
}
.pre{ left:0;
}
.nxt{ right:0;
}
.cr{ width:100%;
height:11px;
bottom:12px;
position:absolute;
text-align:center;
z-index:99;
}
.dts{ position: relative;
display: inline-block;
background:rgba(0,0,0,.4);
}
#t1:checked ~ #one,
#t2:checked ~ #two,
#t3:checked ~ #three{
z-index:99; transition:all 0.5s;
}
<div class="ct">
<input type="radio" name="tabs" id="t1" checked/>
<input type="radio" name="tabs" id="t2"/>
<input type="radio" name="tabs" id="t3"/>
<div class="img_s" id="one">
<div class="im1" style="background-color: #FFF;">01-IMG</div>
<label for="t3" class="pre"><p>❮</p></label>
<label for="t2" class="nxt"><p>❯</p></label>
</div>
<div class="img_s" id="two">
<div class="im2" style="background-color:#0C3;">02-IMG</div>
<label for="t1" class="pre"><p>❮</p></label>
<label for="t3" class="nxt"><p>❯</p></label>
</div>
<div class="img_s" id="three">
<div class="im3" style="background-color:#F63;">03-IMG</div>
<label for="t2" class="pre"><p>❮</p></label>
<label for="t1" class="nxt"><p>❯</p></label>
</div>
</div>
I have a small slide, which works with radios and transition in JS. The code as a whole works normally, only that I intend to increment in javascript that by touching the mouse on top inside the slide box the JS transition of the radios pause giving the chance of the user to click the side arrows and select the images and while removing the mouse from inside the box the transition continues normally, Would it be possible to increase these functions with this simple code in javascript?? I tried here and did not succeed, ?
Save the value returned by the function
setInterval
, in a variable. After this just use the methodsmouseenter
andmouseleave
to detect when the mouse is, or is not, on the slider. Done this just use clearInterval or use this example as base https://stackoverflow.com/a/21278007/9101590– Valdeir Psr
I tried to make with keyframes instead of using this JS, but it didn’t work, however I’m still pretty layabout in JS
– Elienay Junior
There are commands that I do not know in JS and makes it difficult enough, probably I will not hit kkkk, but thanks for the information
– Elienay Junior