我正在尝试创建一个仅 CCS 和 HTML 的图片库滑块。
我已经让滑块工作了,但是每当按下按钮时,焦点就会跳到页面上。
我已经尝试了我能想到的一切,但没有成功:(
任何帮助都会很棒!
HTML:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="Style.css">
</head>
<body>
<div id="container">
<div id="header">
</div> <!-- end of header -->
<nav>
<ul>
<a href="index.html"><li id="HomeButton"><img id="HomeText" src="Images/Icons/HomeText.png" />
</li></a>
<a href="whatswhat.html"><li id="WhatsWhatButton">
<img id="WhatsWhatText" src="Images/Icons/WhatsWhatText.png" />
</li></a>
<a href="FoodFromPlants.html"><li id="FoodFromPlantsButton">
<img id="FoodFromPlantsText" src="Images/Icons/FoodFromPlantsText.png" />
</li></a>
<a href="howplantsgrow.html"><li id="HowPlantsGrowButton">
<div id="HowPlantsGrowText"><img src="Images/Icons/HowPlantsGrowText.png" />
</div>
<div id="HowPlantsGrowIcon"></div>
</li></a>
<a href="plantGame.html"><li id="PlantGameButton">
<img id="PlantGameText" src="Images/Icons/PlantGameText.png" />
</li></a>
</ul>
<form>
<select accesskey="S" onchange="window.location.href=this.value;">
<option value="index.html">Home</option>
<option value="whatswhat.html">Whats What</option>
<option value="FoodFromPlants.html">Food From Plants</option>
<option value="howplantsgrow.html">How Plants Grow</option>
</select>
</form>
</nav> <!-- end of nav -->
<div id="page">
<div id="content">
<img class="title" src="Images/Icons/FoodFromPlantsTitle.png" width="250" height="100"/>
<div id="images">
<img id="image1" src="Images/ImageGallery/Bananas.jpg" />
<img id="image2" src="Images/ImageGallery/Apples.jpg" />
<img id="image3" src="Images/ImageGallery/Broccoli.jpg" />
<img id="image4" src="Images/ImageGallery/Carrots.jpg" />
<img id="image5" src="Images/ImageGallery/Onions.jpg" />
<img id="image6" src="Images/ImageGallery/Peas.jpg" />
</div>
<div id="slider">
<a href="#image1">1</a>
<a href="#image2">2</a>
<a href="#image3">3</a>
<a href="#image4">4</a>
<a href="#image5">5</a>
<a href="#image6">6</a>
</div>
</div> <!-- end of content -->
</div> <!-- end of page -->
<footer>
</footer> <!-- end of footer -->
</div> <!-- end of container -->
</body>
</html>
CSS:
#images {
width: 400px;
height: 250px;
overflow: hidden;
position: relative;
margin: 20px auto;
}
#images img {
width: 400px;
height: 250px;
position: absolute;
top: 0;
left: -400px;
z-index: 1;
opacity: 0;
transition: all linear 500ms;
-o-transition: all linear 500ms;
-moz-transition: all linear 500ms;
-webkit-transition: all linear 500ms;
}
#images img:target {
left: 0;
z-index: 9;
opacity: 1;
}
#images img:first-child {
left: 0;
}
#slider a {
text-decoration: none;
background: #E3F1FA;
border: 1px solid #C6E4F2;
padding: 4px 6px;
color: #222;
}
#slider a:hover {
background: #C6E4F2;
}