美文网首页前端
【前端案例】03 - Bootstrap 实现轮播图 & 不显示

【前端案例】03 - Bootstrap 实现轮播图 & 不显示

作者: itlu | 来源:发表于2020-10-15 17:23 被阅读0次
    1. Bootstrap 实现轮播图 & 不显示左右切换箭头解决方法 (这是最终版)
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>banner</title>
        <link rel="stylesheet" href="./css/bootstrap.min.css">
        <style>
    
            .banner {
                position: relative;
            }
    
            .carousel-control-prev {
                position: absolute;
                top: 50%;
                left: 10px;
                width: 50px;
                height: 50px;
                line-height: 50px;
                text-align: center;
                background-color: rgba(0, 0, 0, .1);
                border-radius: 50%;
                font-size: 26px;
                margin-top: -13px;
                transition: all 0.3s linear;
            }
    
            .carousel-control-next {
                position: absolute;
                top: 50%;
                right: 10px;
                width: 50px;
                height: 50px;
                line-height: 50px;
                text-align: center;
                font-size: 26px;
                background-color: rgba(0, 0, 0, .1);
                border-radius: 50%;
                margin-top: -13px;
                transition: all 0.3s linear;
            }
    
            .carousel-control-prev:hover,
            .carousel-control-next:hover {
                width: 52px;
                height: 52px;
                line-height: 52px;
            }
    
            .carousel-indicators li {
                border-color: #888 !important;
            }
    
        </style>
    </head>
    <body>
    
    <!-- 轮播图 开始 -->
    <div id="myCarousel" class="carousel slide banner" data-ride="carousel" data-interval="2000">
    
       <!-- 轮播 指示图标 -->
        <ol class="carousel-indicators">
            <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
            <li data-target="#myCarousel" data-slide-to="1"></li>
            <li data-target="#myCarousel" data-slide-to="2"></li>
        </ol>
    
        <!-- 轮播图片区域 -->
        <div class="carousel-inner">
            <div class="item active">
                <img src="images/b1.png" alt="" class="img switchImg" data-serial="b1.png">
            </div>
            <div class="item">
                <img src="images/b2.png" alt="" class="img switchImg" data-serial="b2.png">
            </div>
            <div class="item">
                <img src="images/b3.png" alt="" class="img switchImg" data-serial="b3.png">
            </div>
        </div>
    
        <!-- 左右箭头 -->
        <a class="carousel-control-prev" href="#myCarousel" data-slide="prev">
            <span class="glyphicon glyphicon-chevron-left"></span>
        </a>
    
        <a class="carousel-control-next" href="#myCarousel" data-slide="next">
            <span class="glyphicon glyphicon-chevron-right"></span>
        </a>
    
    </div>
    <!-- 轮播图 结束 -->
    
    <script src="./js/jquery.min.js"></script>
    <script src="./js/bootstrap.min.js"></script>
    </body>
    </html>
    
    1. 更换图标样式图标就可以出现:
    更换图标样式
    1. 再对图标位置及样式进行修改:
            .banner {
                position: relative;
            }
    
            .carousel-control-prev {
                position: absolute;
                top: 50%;
                left: 10px;
                width: 50px;
                height: 50px;
                line-height: 50px;
                text-align: center;
                background-color: rgba(0, 0, 0, .1);
                border-radius: 50%;
                font-size: 26px;
                margin-top: -13px;
                transition: all 0.3s linear;
            }
    
            .carousel-control-next {
                position: absolute;
                top: 50%;
                right: 10px;
                width: 50px;
                height: 50px;
                line-height: 50px;
                text-align: center;
                font-size: 26px;
                background-color: rgba(0, 0, 0, .1);
                border-radius: 50%;
                margin-top: -13px;
                transition: all 0.3s linear;
            }
    
            .carousel-control-prev:hover,
            .carousel-control-next:hover {
                width: 52px;
                height: 52px;
                line-height: 52px;
            }
    
            .carousel-indicators li {
                border-color: #888 !important;
            }
    
    

    相关文章

      网友评论

        本文标题:【前端案例】03 - Bootstrap 实现轮播图 & 不显示

        本文链接:https://www.haomeiwen.com/subject/axsopktx.html