您的位置:MYSQL中文网 > bootstrap4轮播 Bootstrap4 轮播

bootstrap4轮播 Bootstrap4 轮播

2023-06-13 12:30 bootstrap4教程

bootstrap4轮播 Bootstrap4 轮播

bootstrap4轮播

Bootstrap4轮播是一种基于Bootstrap4框架的轮播图片效果,它可以帮助用户快速创建一个美观的、动态的、响应式的轮播图片效果。它可以帮助用户在网站上显示多张图片,并且可以根据用户的需要进行自定义。

Bootstrap4轮播使用了HTML、CSS和JavaScript来创建一个动态的、响应式的轮播图片效果。它使用了Bootstrap4中的Carousel组件,可以帮助用户快速创建一个美观的、动态的、响应式的轮播图片效果。

<div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img src="..." class="d-block w-100" alt="...">
    </div>
    <div class="carousel-item">
      <img src="..." class="d-block w-100" alt="...">
    </div>
    ...
  </div>

  <a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">  // 向前切换 

    <span class="carousel-control-prev-icon" aria-hidden="true"></span>

    <a class=”sr-only” href=”#carouselExampleControls” role=”button” data slide=”prev”>Previous// 向前切换文字说明

  <span class=”sr only” aria hidden=true /span

  <span class=”sr only” aria hidden=true /span

  <span class=”sr only” aria hidden=true /span

  <span class=”sr only” aria hidden=true /span

   // 向后切换  

   <a class = “ carousel control next “ href = “ # carouselexamplecontrols “ role = “ button “ data slide = “ next “ >  

   // 向后切换文字说明  

   Next < / span > < / a > < / div > < / div > < pre >

Bootstrap4 轮播

轮播是一个一个幻灯片组件,用来循环显示图片元素,或者滚动的文字。

轮播创建

以下实例创建了一个简单的图片轮播效果 :

实例:

<!DOCTYPE html>
<html>
<head>
  <title>Bootstrap4 实例</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="external nofollow" target="_blank"  rel="external nofollow" target="_blank" >
  <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js" rel="external nofollow"  rel="external nofollow" ></script>
  <script src="https://cdn.bootcss.com/popper.js/1.12.5/umd/popper.min.js" rel="external nofollow"  rel="external nofollow" ></script>
  <script src="https://cdn.bootcss.com/bootstrap/4.1.0/js/bootstrap.min.js" rel="external nofollow"  rel="external nofollow" ></script>
  <style>
  
  .carousel-inner img {
      width: 100%;
      height: 100%;
  }
  </style>
</head>
<body>
<div id="demo" class="carousel slide" data-ride="carousel">
  <!-- 指示符 -->
  <ul class="carousel-indicators">
    <li data-target="#demo" data-slide-to="0" class="active"></li>
    <li data-target="#demo" data-slide-to="1"></li>
    <li data-target="#demo" data-slide-to="2"></li>
  </ul>
  <!-- 轮播图片 -->
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img src="https://atts..cn/attachments/knowledge/201803/24575.png">
    </div>
    <div class="carousel-item">
      <img src="https://atts..cn/attachments/knowledge/201801/31740.png">
    </div>
    <div class="carousel-item">
      <img src="https://atts..cn/attachments/knowledge/201804/30601.png">
    </div>
  </div>
  <!-- 左右切换按钮 -->
  <a class="carousel-control-prev" href="#demo" data-slide="prev">
    <span class="carousel-control-prev-icon"></span>
  </a>
  <a class="carousel-control-next" href="#demo" data-slide="next">
    <span class="carousel-control-next-icon"></span>
  </a>
</div>
</body>
</html>

轮播图片上添加描述

在每个 <div class="carousel-item"> 内添加 <div class="carousel-caption"> 来设置轮播图片的描述文本::

实例:

<!DOCTYPE html>
<html>
<head>
  <title>Bootstrap4 实例</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="external nofollow" target="_blank"  rel="external nofollow" target="_blank" >
  <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js" rel="external nofollow"  rel="external nofollow" ></script>
  <script src="https://cdn.bootcss.com/popper.js/1.12.5/umd/popper.min.js" rel="external nofollow"  rel="external nofollow" ></script>
  <script src="https://cdn.bootcss.com/bootstrap/4.1.0/js/bootstrap.min.js" rel="external nofollow"  rel="external nofollow" ></script>
  <style>
  
  .carousel-inner img {
      width: 100%;
      height: 100%;
  }
  </style>
</head>
<body>
<div id="demo" class="carousel slide" data-ride="carousel">
  <!-- 指示符 -->
  <ul class="carousel-indicators">
    <li data-target="#demo" data-slide-to="0" class="active"></li>
    <li data-target="#demo" data-slide-to="1"></li>
    <li data-target="#demo" data-slide-to="2"></li>
  </ul>
  <!-- 轮播图片 -->
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img src="https://atts..cn/attachments/knowledge/201803/24575.png">
      <div class="carousel-caption">
        <h3>第一张图片描述标题</h3>
        <p>描述文字!</p>
      </div>
    </div>
    <div class="carousel-item">
      <img src="https://atts..cn/attachments/knowledge/201702/43125.png">
      <div class="carousel-caption">
        <h3>第二张图片描述标题</h3>
        <p>描述文字!</p>
      </div>
    </div>
    <div class="carousel-item">
      <img src="https://atts..cn/attachments/knowledge/201804/30601.png">
      <div class="carousel-caption">
        <h3>第三张图片描述标题</h3>
        <p>描述文字!</p>
      </div>
    </div>
  </div>
  <!-- 左右切换按钮 -->
  <a class="carousel-control-prev" href="#demo" data-slide="prev">
    <span class="carousel-control-prev-icon"></span>
  </a>
  <a class="carousel-control-next" href="#demo" data-slide="next">
    <span class="carousel-control-next-icon"></span>
  </a>
</div>
</body>
</html>


阅读全文
以上是MYSQL中文网为你收集整理的bootstrap4轮播 Bootstrap4 轮播全部内容。
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。
相关文章
© 2024 MYSQL中文网 mysqlcn.com 版权所有 联系我们
桂ICP备12005667号-29 Powered by CMS