簡體   English   中英

引導程序:輪播無法正常工作

[英]Bootstrap: Carousel not working

嘗試在我正在創建的網頁中使用輪播。 輪播中應包含3張圖像,但這些圖像只是一個堆疊在另一個之上。 該索引文件位於一個文件夾中,該文件夾還包含css,fonts和js文件夾。 我不確定這是否是小事,但我無法弄清楚。

 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> <title>Bootstrap 101 Template</title> <!-- Bootstrap --> <link href="css/bootstrap.css" rel="stylesheet"> <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"> </script> <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"> </script> <![endif]--> </head> <body> <div id="carouselControls" class="carousel slide" data-ride="carousel"> <div class="carousel-inner" role="listbox"> <div class="carousel-item active"> <a href="#"> <img class="d-block img-fluid" src="https://fgl.scene7.com/is/image/FGLSportsLtd/332266454_99_a ? wid=288&hei=288&op_sharpen=1&resMode=sharp2" alt="First slide"> </a> </div> <div class="carousel-item"> <a href="#"> <img class="d-block img-fluid" src="https://fgl.scene7.com/is/image/FGLSportsLtd/332266454_99_a ? wid=288&hei=288&op_sharpen=1&resMode=sharp2" alt="Second slide"> </a> </div> <div class="carousel-item"> <a href="#"> <img class="d-block img-fluid" src="https://fgl.scene7.com/is/image/FGLSportsLtd/332266454_99_a ? wid=288&hei=288&op_sharpen=1&resMode=sharp2" alt="Third slide"> </a> </div> </div> </div> <a class="carousel-control-prev" href="#carouselControls" role="button" data-slide="prev"> <span class="carousel-control-prev-icon" aria-hiddin="true"></span> <span class="sr-only">Previous</span> </a> <a class="carousel-control-next" href="carouselControls" role="button" data-slide="next"> <span class="carousel-control-next-icon" aria-hidden="true"></span> <span class="sr-only">Next</span> </a> </div> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> <!-- Include all compiled plugins (below), or include individual files as needed --> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> </body> </html> 

在JSFiddle上: https ://jsfiddle.net/057z6f35/1/

問題與您擁有的引導程序版本有關。 我懷疑您正在使用bootstrap3.x。 在這種情況下,輪播內部項目需要具有“項目”類別而不是“輪播項目”。 輪播項目類別適用於v4 alpha版本。 更新您的代碼,使其看起來像:

    <div class="carousel-inner" role="listbox">
        <div class="item active">
            <a href="#">
            <img class="d-block img-fluid" 
            src="https://fgl.scene7.com/is/image/FGLSportsLtd/332266454_99_a
            ? wid=288&hei=288&op_sharpen=1&resMode=sharp2" alt="First 
            slide">
            </a>
        </div>
        <div class="item">
            <a href="#">
            <img class="d-block img-fluid" 
            src="https://fgl.scene7.com/is/image/FGLSportsLtd/332266454_99_a
            ? wid=288&hei=288&op_sharpen=1&resMode=sharp2" alt="Second 
            slide">
            </a>
        </div>
        <div class="item">
            <a href="#">
            <img class="d-block img-fluid" 
            src="https://fgl.scene7.com/is/image/FGLSportsLtd/332266454_99_a 
            ? wid=288&hei=288&op_sharpen=1&resMode=sharp2" alt="Third 
            slide">
            </a>
        </div>
    </div>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM