Ну, я пытаюсь сделать слайд-шоу с перекрывающейся надписью при наведении курсора на контейнер или изображение. Изображение должно быть точно вписано в коробку контейнера, чтобы на нем не отображалась полоса прокрутки, а радиус границы был правильным. Я смог сделать это, однако есть ошибка. Когда страница загружается первой, это нормально, но мерцание происходит, и появляется полоса прокрутки, или инверсия (сначала полоса прокрутки есть, а затем нет). Есть ли способ решить эту проблему?


Я проверил с Chrome и Firefox, и оба демонстрируют одинаковое некорректное поведение.
var slideIndex = 1;
showSlides(slideIndex);
// Next/previous controls
function plusSlides(n) {
showSlides(slideIndex += n);
}
function currentSlide(n) {
showSlides(slideIndex = n);
}
function showSlides(n) {
var i;
var slides = document.getElementsByClassName("slide");
var dots = document.getElementsByClassName("dot");
if (n > slides.length) {
slideIndex = 1
} else if (n < 1) {
slideIndex = slides.length
}
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
dots[i].className = dots[i].className.replace(" active", "");
}
slides[slideIndex - 1].style.display = "block";
dots[slideIndex - 1].className += " active";
}
@charset "UTF-8";
* {
margin: 0px;
padding: 0px;
}
#header {
background-color: #202020;
height: 120px;
overflow: auto;
}
body {
background-color: #f5f5f5;
}
.navbar li {
display: inline;
margin-left: 50px;
}
.navbar {
font-family: "Roboto Thin";
font-size: 20pt;
color: white;
list-style-type: none;
padding-top: 48px;
margin-left: 400px;
}
#login {
font-size: 14pt;
color: white;
float: right;
padding-top: 57px;
padding-right: 35px;
}
#login li {
display: inline;
margin-left: 10px;
}
.titulo {
font-family: "Roboto Light";
font-size: 45pt;
}
img#mds-modern {
float: left;
padding-top: 15px;
height: 100px;
}
img#mds-logo {
float: left;
height: 120px;
}
div.body {
padding-top: 20px;
}
.carousel-container {
max-width: 773px;
max-height: 509px;
border-radius: 10px;
position: relative;
margin: auto;
overflow: auto;
}
.slide {
display: none;
}
.slide img {
width: 100%;
height: 100%;
}
.prev,
.next {
cursor: pointer;
position: absolute;
top: 50%;
width: auto;
margin-top: -22px;
padding: 16px;
color: white;
font-weight: bold;
font-size: 18px;
transition: 0.6s ease;
border-radius: 0 3px 3px 0;
user-select: none;
}
.next {
right: 0;
border-radius: 3px 0 0 3px;
}
.prev:hover,
.next:hover {
background-color: rgba(0, 0, 0, 0.8);
}
.caption {
height: 50px;
color: rgba(242, 242, 242, 0);
font-size: 20pt;
font-family: "Roboto Thin";
padding-top: 12.5px;
position: absolute;
bottom: 0px;
width: 100%;
text-align: center;
}
.carousel-container:hover .caption {
background: linear-gradient(rgba(0, 0, 0, 0.1), rgba(25, 25, 25, 0.8));
color: #f2f2f2;
transition: background 2s;
}
.dot {
cursor: pointer;
height: 15px;
width: 15px;
margin: 0 2px;
background-color: #bbb;
border-radius: 50%;
display: inline-block;
transition: background-color 0.6s ease;
}
.active,
.dot:hover {
background-color: #717171;
}
.fade {
-webkit-animation-name: fade;
-webkit-animation-duration: 1.5s;
animation-name: fade;
animation-duration: 1.5s;
}
.row::after {
content: "";
display: table;
clear: both;
}
.column {
float: left;
width: 33.33%;
}
@-webkit-keyframes fade {
from {
opacity: .4
}
to {
opacity: 1
}
}
@keyframes fade {
from {
opacity: .4
}
to {
opacity: 1
}
}