Javascript图像滑块高度问题
我一直在致力于基于W3Slider制作我的on image slider,但我希望它有所不同。现在我还不太擅长html和css,我似乎无法找到为什么Overlysee图像比img稍微大一点,我也无法找到与img高度匹配的解决方案 我以为是图像改变了好几次,但这似乎解决不了问题 还包括代码 HTML JavascriptJavascript图像滑块高度问题,javascript,css,html,Javascript,Css,Html,我一直在致力于基于W3Slider制作我的on image slider,但我希望它有所不同。现在我还不太擅长html和css,我似乎无法找到为什么Overlysee图像比img稍微大一点,我也无法找到与img高度匹配的解决方案 我以为是图像改变了好几次,但这似乎解决不了问题 还包括代码 HTML Javascript 您可以使用此技巧来实现您的目标: .slideshow-container { font-size: 0; } 谢谢在过去的一个小时里,我一直在寻找解决方案,这让我省去了很
您可以使用此技巧来实现您的目标:
.slideshow-container {
font-size: 0;
}
谢谢在过去的一个小时里,我一直在寻找解决方案,这让我省去了很多头痛!
/* Slideshow container */
.slideshow-container {
max-width: 1000px;
position: relative;
overflow: hidden;
}
/* Next & previous buttons */
.prev, .next {
cursor: pointer;
position: absolute;
top: 0;
height: 100%;
padding-left: 5%;
padding-right: 5%;
transition: 0.6s ease;
}
.arrows{
position: absolute;
top: 50%;
left: 40%;
color: white;
font-weight: bold;
font-size: 18px;
}
/* Position the "next button" to the right */
.next {
right: 0;
}
/* On hover, add a black background color with a little bit see-through */
.prev:hover, .next:hover {
background-color: rgba(0,0,0,0.4);
}
/* Caption text */
.dot-container {
position: absolute;
bottom: 8px;
width: 100%;
text-align: center;
}
/* The dots/bullets/indicators */
.dot {
cursor:pointer;
height: 13px;
width: 13px;
margin: 0 2px;
background-color: #bbb;
border-radius: 50%;
display: inline-block;
transition: background-color 0.6s ease;
}
.active, .dot:hover {
background-color: #717171;
}
/* Fading animation */
.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}
}
@media only screen and (max-width: 500px) {
.slideshow-container {
max-width: 80%;
}
}
var slideIndex = 0;
var clicked;
var i;
var slides = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("dot");
slide();
function slide()
{
if(!clicked){
autoSlide();
}else{
showSlides(slideIndex);
}
}
function plusSlides(n) {
showSlides(slideIndex += n);
clicked = true;
}
function currentSlide(n) {
showSlides(slideIndex = n);
clicked = true;
}
function showSlides(n) {
if (n > slides.length) {slideIndex = 1}
if (n < 1) {slideIndex = slides.length}
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active", "");
}
slides[slideIndex-1].style.display = "";
dots[slideIndex-1].className += " active";
}
function autoSlide()
{
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active", "");
}
slideIndex++;
if (slideIndex> slides.length) {slideIndex = 1}
slides[slideIndex-1].style.display = "block";
dots[slideIndex-1].className += " active";
setTimeout(slide, 5000); // Change image every 5 seconds
}
.slideshow-container {
font-size: 0;
}