因此,當我在html index.html應該顯示的地方顯示html和css代碼時,網頁瀏覽器如何顯示每張圖片,尤其是當我點擊下一個箭頭時,它變成了幻燈片,不再顯示圖片。
html {
background: url('./images/cover2.jpg') no-repeat center fixed;
background-size: cover;
}
body{
font-family: 'Source Sans Pro', sans-serif;
color: white;
margin-top: 130px;
margin-left: 0px;
height: 125vh;
padding: 1px;
}
.ImgNavagation{
height: 90px;
position: absolute;
top: 0;
left: 0;
right: 0;
background-color: white;
opacity: 0.92;
max-width: 100%;
align-items: center;
display: flex;
}
h1{
font-weight: bolder;
font-size: 50px;
color: black;
max-width: 100%;
}
.navigation {
display: flex;
justify-content: space-evenly;
list-style: none;
max-width: 100%;
}
.location-cont1{
margin: 10px;
float: left;
}
.location-cont2{
margin: 10px;
float: left;
}
li{
list-style-type: none;
}
.ImgNavagation *{
display:inline;
margin: 5px;
}
.slideshow-container {
position: relative;
max-width: 1000px;
margin: auto;
}
.myslides{
display: none;
}
.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,0.34);
}
.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{
animation-name: fade;
animation-duration: 1.0s;
}
@keyframes fade{
from {opacity: .4}
to {opacity: 1}
}
.mission_content{
margin: 1px 0px 1px 0px;
border: 1.5px solid white;
max-width: 895px;
}
#About{
margin: 1px 0px 1px 0px;
border: 1.5px solid white;
max-width: 895px;
}
#Contact{
background-color: #282424;
overflow: hidden;
position: relative;
bottom: 0;
left: 0;
width: 100%;
}
#Contact a{
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: underline;
font-size: 17px;
}
#Contact a:hover{
background-color: #E91E63;
border-radius : 20%;
color: white;
}
#ontact a:active{
background-color: #E91E63;
border-radius : 20%;
color: white;
}
<!--<body>-->
<div class = "ImgNavagation">
<img src="./images/bookicon.png" width="80" height="40" >
<h1>Singh Books & Co.</h1>
<ul class="navigation">
<li class=" navigation nav-success"><a href="#About">About</a></li>
<li class=" navigation nav-success"><a href="#location">Location</a></li>
<li class=" navigation nav-success"><a href="#Contact">ContactUS</a></li>
</ul>
</div>
<div class="slideshow-container">
<div class="mySlides fade">
<img src="./images/insidelook1.jpg" style="width: 100%">
</div>
<div class="mySlides fade">
<img src="./images/insidelook2.jpg" style="width: 100%">
</div>
<div class="mySlides fade">
<img src="./images/insidelook3.jpg" style="width: 100%">
</div>
<a class="prev" onclick="plusSlides(-1)">❮</a>
<a class="next" onclick="plusSlides(1)">❯</a>
</div>
<div style="text-align:center">
<span class="dot" onclick="currentSlide(1)"></span>
<span class="dot" onclick="currentSlide(2)"></span>
<span class="dot" onclick="currentSlide(3)"></span>
</div>
<h2>Mission</h2>
<div class = "mission_content">
<p>Our mission is Singh book is provide every book, meet customer demand and supply and
serve a best customer service. Also we buy book from buyer they want to sell.
</p>
</div>
<h2>About Us</h2>
<div id="About">
<p>Singh Book & Co. is owned by Harry Singh since 1990.
Singh Book & Co have multiple location around Ohio, Michgan and ship nationwide USA.
Stores are Open until 8am - 6pm and 24/7 for nationwide order.
Singh Book & Co. Carry every genere type of books Fiction, Non-fiction, Memiors...etc.
Also have different format of book hardcover or paperback.
</p>
</div>
<div id="location">
<h2>Location:</h2>
<div class="location-cont1">
<h4>Ohio:</h4>
<ul>
<li>Toledo</li>
<li>Cleveland</li>
<li>Dayton</li>
<li>Cinncanti</li>
<li>Colmubus</li>
<li>Sandusky</li>
</ul>
</div>
<div class="location-cont2">
<h4>Michgan:</h4>
<ul>
<li>Grand Rapid</li>
<li>Detroit</li>
<li>Farmightion Hill</li>
<li>Novi</li>
<li>Travese City</li>
</ul>
</div>
</div>
<div id="Contact">
<h3>Support Service:</h3>
<a>Email Address: SinghbookCo@gmail.com</a>
<a>Phone Number: 3214892034</a>
</div>
<!-- </body>
</html>-->
# # #如前所述,只需快速瀏覽一下,您就可以調用沒有定義的事件。 在這些行中:
<a class="prev" onclick="plusSlides(-1)">❮</a>
<a class="next" onclick="plusSlides(1)">❯</a>
& amp
<div style="text-align:center">
<span class="dot" onclick="currentSlide(1)"></span>
<span class="dot" onclick="currentSlide(2)"></span>
<span class="dot" onclick="currentSlide(3)"></span>
“onClick”屬性被設置為一個JavaScript函數,一個是currentSlide(x ),另一個是plus slides(y ), x和y是傳遞給它們的參數。
“onClick”屬性是一個事件,當您單擊相應的元素時,它基本上執行您在其中編寫的任何操作,并且通常使用JavaScript函數,當您單擊某個元素時,它可以交互地對您的HTML執行操作。在你的情況下:改變幻燈片中的圖片。這些功能可以在另一個中定義。js文件,然后你必須把它作為一個外部文件加載,就像你對css所做的那樣(你的HTML的一部分丟失了,所以很難說)。或者您可以直接在index.html內部使用標簽。
如果您確實有相應的JS,請將其添加到您的問題中,我們可以提供進一步的幫助。