Some questions:
1) If we reduce the height
of the browser by changing the resolution, div.slider
does not match the height of div.slide
. That is, it keeps the same height. Soon, the image will be small, the div.slider
high, and the controls next and previous below.
2) The SPAN descriptions of the images is above the NAV that houses the navigation buttons. The problem here is that I can not navigate because of this. And if I put SPAN with a small size and throw it forward then I can navigate, but I can not centralize the SPAN .
3) There is still one last question. But this is the same level of teaching. In the code below you have:
.slide {
position: absolute;
display: none;
width: 100%;
height:100%;
}
But if I put div.slide
instead of .slide
, although it is a div , the slide disappears and the page loads blank. What is happening at this event?
Can anyone help me please?
Code below:
$(document).ready(function(e) {
function startslider(dir) {
ativa = $("div.slider div.ativa")
ativa.removeClass("ativa");
if(dir == -1)
$('div.slider').prepend($('div.slider div.slide').last());
else
$('div.slider nav').before(ativa);
$('div.slider div.slide').eq(0).addClass('ativa');
timer = setTimeout(startslider, 2000);
}
$('div.slider nav button.proximo').on('click', function() {
clearTimeout(timer);
startslider(1);
});
$('div.slider nav button.anterior').on('click', function() {
clearTimeout(timer);
startslider(-1);
});
var timer = setTimeout(startslider, 2000);
});
* {
margin: 0;
padding: 0;
}
.fade {
-webkit-animation-name: fade;
-webkit-animation-duration: 1.5s;
animation-name: fade;
animation-duration: 1.5s;
}
@-webkit-keyframes fade {
from {
opacity: .4
}
to {
opacity: 1
}
}
@keyframes fade {
from {
opacity: .4
}
to {
opacity: 1
}
}
div.slider {
position: relative;
width: 100vw;
height:360px;
overflow: hidden;
}
.slide {
position: absolute;
display: none;
width: 100%;
height:100%;
}
.ativa {
display: block;
}
.ativa img {
width:100%;
height:auto;
animation: slider 1s linear;
animation-fill-mode: forwards;
}
@keyframes slider {
0% {
transform: scale(1);
}
100% {
transform: scale(1.1);
}
}
.ativa img:hover {
-moz-transition: all 0.3s;
-webkit-transition: all 0.3s;
transition: all 0.3s;
}
div.slider div.slide span {
position: absolute;
width: 100%;
bottom: 0;
height: 40px;
line-height: 40px;
text-align: center;
color: rgb(255,255,255);
z-index: 500;
}
div.slider nav {
position: absolute;
width: 100%;
height: 40px;
bottom: 0;
text-align: center;
background-color: rgb(0, 0, 0, .5);
z-index: 400;
}
div.slider nav button.anterior, div.slider nav button.proximo {
position: absolute;
width: 100px;
height: 40px;
text-align: center;
}
div.slider nav button.anterior {
left: 10%;
}
div.slider nav button.proximo {
right: 10%;
}
div.slider nav button.proximo label {
top: calc(50%-20px);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><divclass="slider">
<div class="slide ativa">
<img class="fade" src="http://funerariasaopedro.net.br/novo/_img/_banner/_site/bg_1.jpg"/><span>Esteé1</span></div><divclass="slide">
<img class="fade" src="http://funerariasaopedro.net.br/novo/_img/_banner/_site/bg_2.jpg"/><span>Esteé2</span></div><divclass="slide">
<img class="fade" src="http://funerariasaopedro.net.br/novo/_img/_banner/_site/bg_3.jpg"/><span>Esteé3</span></div><nav><buttonclass="anterior">Anterior</button>
<button class="proximo">Próximo</button>
</nav>
</div>