Bootstrap -- 插件: 按鈕狀態、折疊樣式、輪播樣式


 Bootstrap -- 插件: 按鈕狀態、折疊樣式、輪播樣式

1. 按鈕(Button)插件:可以添加進一些交互,比如控制按鈕狀態。

如需向按鈕添加加載狀態,只需要簡單地向 button 元素添加 data-loading-text="Loading..." 作為其屬性即可。

為按鈕添加加載狀態:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>My Test bootstrap</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script>
        $(function() {
            $(".btn").click(function(){
                $(this).button('loading').delay(1000).queue(function() {
                    $(this).button('reset');
                    $(this).dequeue(); 
                });
            });
        });  
    </script>
</head>
<body>     
    <button id="fat-btn" class="btn btn-primary" data-loading-text="Loading..." type="button"> 加載狀態
</button>
</body>
</html>
View Code

樣式效果:

 

2. 折疊(Collapse)插件:可以很容易地讓頁面區域折疊起來。無論您用它來創建折疊導航還是內容面板,它都允許很多內容選項。

使用折疊樣式:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>My Test bootstrap</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>         
<div class="panel-group" id="accordion">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h4 class="panel-title">
                <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
                點擊展開
                </a>
            </h4>
        </div>
        <div id="collapseOne" class="panel-collapse collapse in">
            <div class="panel-body">
                展開的內容:折疊(Collapse)插件可以很容易地讓頁面區域折疊起來。無論您用它來創建折疊導航還是內容面板,它都允許很多內容選項。
    如果您想要單獨引用該插件的功能,那么您需要引用 collapse.js。同時,也需要在您的 Bootstrap 版本中引用 Transition(過渡)插件。
            </div>
        </div>
    </div>
</div>
</body>
</html>
View Code

樣式效果:

 

3. 輪播(Carousel)插件:是一種靈活的響應式的向站點添加滑塊的方式。

使用輪播樣式:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>My Test bootstrap</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>         
    <div id="myCarousel" class="carousel slide">
        <ol class="carousel-indicators">
            <li data-target="#myCarousel" data-slide-to="0" class="active">1</li>
            <li data-target="#myCarousel" data-slide-to="1">2</li>
            <li data-target="#myCarousel" data-slide-to="2">3</li>
        </ol>   
        <div class="carousel-inner">
            <div class="item active">
                <img src="./img/test1.jpg" alt="第一張桌面背景">
            </div>
            <div class="item">
                <img src="./img/test2.jpg" alt="第二張桌面背景">
            </div>
            <div class="item">
                <img src="./img/test3.jpg" alt="第三張桌面背景">
            </div>
        </div>

    </div>
</body>
</html>
View Code

樣式效果:

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM