📜  如何在每张幻灯片中显示三个职位的引导轮播?(1)

📅  最后修改于: 2023-12-03 15:38:40.694000             🧑  作者: Mango

如何在每张幻灯片中显示三个职位的引导轮播?

如果你想在每张幻灯片中显示三个职位的引导轮播,可以考虑使用Bootstrap的Carousel组件。在Carousel组件中,可以设置每个Slide显示多个Item,从而实现在每张幻灯片中显示多个内容的效果。

以下是具体实现步骤:

  1. 引入Bootstrap的CSS和JS文件 在头部(head)引入Bootstrap的CSS和JS文件:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  1. 编写Carousel的HTML结构 在页面中编写Carousel的HTML结构,其中每个Slide内部包含多个Item。注意设置Carousel的class和data属性,同时指定Item的class和宽度:
<div id="myCarousel" class="carousel slide" data-ride="carousel">
  <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" role="listbox">
    <!-- Slide 1 -->
    <div class="item active">
      <div class="row">
        <div class="col-md-4">
          <!-- Item 1 -->
          <div class="thumbnail">
            <div class="caption">
              <h4>职位1</h4>
              <p>职位描述1</p>
            </div>
          </div>
        </div>
        <div class="col-md-4">
          <!-- Item 2 -->
          <div class="thumbnail">
            <div class="caption">
              <h4>职位2</h4>
              <p>职位描述2</p>
            </div>
          </div>
        </div>
        <div class="col-md-4">
          <!-- Item 3 -->
          <div class="thumbnail">
            <div class="caption">
              <h4>职位3</h4>
              <p>职位描述3</p>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- Slide 2 -->
    <div class="item">
      <div class="row">
        <div class="col-md-4">
          <!-- Item 4 -->
          <div class="thumbnail">
            <div class="caption">
              <h4>职位4</h4>
              <p>职位描述4</p>
            </div>
          </div>
        </div>
        <div class="col-md-4">
          <!-- Item 5 -->
          <div class="thumbnail">
            <div class="caption">
              <h4>职位5</h4>
              <p>职位描述5</p>
            </div>
          </div>
        </div>
        <div class="col-md-4">
          <!-- Item 6 -->
          <div class="thumbnail">
            <div class="caption">
              <h4>职位6</h4>
              <p>职位描述6</p>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- Slide 3 -->
    <div class="item">
      <div class="row">
        <div class="col-md-4">
          <!-- Item 7 -->
          <div class="thumbnail">
            <div class="caption">
              <h4>职位7</h4>
              <p>职位描述7</p>
            </div>
          </div>
        </div>
        <div class="col-md-4">
          <!-- Item 8 -->
          <div class="thumbnail">
            <div class="caption">
              <h4>职位8</h4>
              <p>职位描述8</p>
            </div>
          </div>
        </div>
        <div class="col-md-4">
          <!-- Item 9 -->
          <div class="thumbnail">
            <div class="caption">
              <h4>职位9</h4>
              <p>职位描述9</p>
            </div>
          </div>
        </div>
      </div>
    </div>

  </div>

  <!-- Controls -->
  <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
    <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
  </a>
  <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
    <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
  </a>

</div>
  1. CSS样式设置 设置Carousel的CSS样式和每个Item的CSS样式,使其符合设计要求:
#myCarousel.carousel {
  margin-bottom: 0;
}

/* Item */
#myCarousel .item {
  text-align: center;
}

/* Thumbnail */
#myCarousel .thumbnail {
  padding: 0;
  border: none;
}

/* Caption */
#myCarousel .caption {
  padding: 10px;
  background: #f5f5f5;
}

/* Active Item */
#myCarousel .carousel-inner > .active {
  display: flex;
}

/* Item Width */
#myCarousel .item > div[class*='col-'] {
  display: flex;
  flex-direction: column;
}

完成上述步骤后,便可在每张幻灯片中显示三个职位的引导轮播。

返回的代码片段:

# 如何在每张幻灯片中显示三个职位的引导轮播?

如果你想在每张幻灯片中显示三个职位的引导轮播,可以考虑使用Bootstrap的Carousel组件。在Carousel组件中,可以设置每个Slide显示多个Item,从而实现在每张幻灯片中显示多个内容的效果。

以下是具体实现步骤:

1. 引入Bootstrap的CSS和JS文件
在头部(head)引入Bootstrap的CSS和JS文件:

```html
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  1. 编写Carousel的HTML结构 在页面中编写Carousel的HTML结构,其中每个Slide内部包含多个Item。注意设置Carousel的class和data属性,同时指定Item的class和宽度:
<div id="myCarousel" class="carousel slide" data-ride="carousel">
  <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" role="listbox">
    <!-- Slide 1 -->
    <div class="item active">
      <div class="row">
        <div class="col-md-4">
          <!-- Item 1 -->
          <div class="thumbnail">
            <div class="caption">
              <h4>职位1</h4>
              <p>职位描述1</p>
            </div>
          </div>
        </div>
        <div class="col-md-4">
          <!-- Item 2 -->
          <div class="thumbnail">
            <div class="caption">
              <h4>职位2</h4>
              <p>职位描述2</p>
            </div>
          </div>
        </div>
        <div class="col-md-4">
          <!-- Item 3 -->
          <div class="thumbnail">
            <div class="caption">
              <h4>职位3</h4>
              <p>职位描述3</p>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- Slide 2 -->
    <div class="item">
      <div class="row">
        <div class="col-md-4">
          <!-- Item 4 -->
          <div class="thumbnail">
            <div class="caption">
              <h4>职位4</h4>
              <p>职位描述4</p>
            </div>
          </div>
        </div>
        <div class="col-md-4">
          <!-- Item 5 -->
          <div class="thumbnail">
            <div class="caption">
              <h4>职位5</h4>
              <p>职位描述5</p>
            </div>
          </div>
        </div>
        <div class="col-md-4">
          <!-- Item 6 -->
          <div class="thumbnail">
            <div class="caption">
              <h4>职位6</h4>
              <p>职位描述6</p>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- Slide 3 -->
    <div class="item">
      <div class="row">
        <div class="col-md-4">
          <!-- Item 7 -->
          <div class="thumbnail">
            <div class="caption">
              <h4>职位7</h4>
              <p>职位描述7</p>
            </div>
          </div>
        </div>
        <div class="col-md-4">
          <!-- Item 8 -->
          <div class="thumbnail">
            <div class="caption">
              <h4>职位8</h4>
              <p>职位描述8</p>
            </div>
          </div>
        </div>
        <div class="col-md-4">
          <!-- Item 9 -->
          <div class="thumbnail">
            <div class="caption">
              <h4>职位9</h4>
              <p>职位描述9</p>
            </div>
          </div>
        </div>
      </div>
    </div>

  </div>

  <!-- Controls -->
  <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
    <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
  </a>
  <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
    <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
  </a>

</div>
  1. CSS样式设置 设置Carousel的CSS样式和每个Item的CSS样式,使其符合设计要求:
#myCarousel.carousel {
  margin-bottom: 0;
}

/* Item */
#myCarousel .item {
  text-align: center;
}

/* Thumbnail */
#myCarousel .thumbnail {
  padding: 0;
  border: none;
}

/* Caption */
#myCarousel .caption {
  padding: 10px;
  background: #f5f5f5;
}

/* Active Item */
#myCarousel .carousel-inner > .active {
  display: flex;
}

/* Item Width */
#myCarousel .item > div[class*='col-'] {
  display: flex;
  flex-direction: column;
}

完成上述步骤后,便可在每张幻灯片中显示三个职位的引导轮播。