1

我正在尝试创建三个垂直点并将容器的左下角与 css 和 bootstrap 5 对齐。就像下图一样:

在此处输入图像描述

我的 HTML 和 CSS:

.dot {
  border-radius: 50%;
  height: 12px;
  width: 12px;
  background: linear-gradient(90deg, #76b3fe, #8680e4);
}

.selected-dot {
  height: 20px;
  width: 20px;
  background: #97cdfe;
}
<section class="slider-bg-1 d-flex align-items-end">
  <div class="container">
    <div class="row justify-content-center">
      <div class="col-lg-5 d-flex flex-column justify-content-center pt-4 pt-lg-0 order-2 order-lg-1">
        <h1 class="head-font-size">Choose a powerful design for your Start-up</h1>
        <h6 claas="caption-text-color">Get your freebie template now</h6>
        <div class="d-lg-flex">
          <div class="mt-5"><button class="my-btn" type="submit">Discover</button></div>
        </div>
      </div>
      <div class="col-lg-5 col-md-12 col-sm-12 order-1 order-lg-2 d-flex justify-content-center">
        <img src="Assets/home-slider/slider-m-1.png" class="img-fluid img-slider" alt="">
      </div>
    </div>
  </div>

  <span class="dot selected-dot"></span>
  <span class="dot"></span>
  <span class="dot"></span>
</section>

这是我的输出 在此处输入图像描述

如何垂直对齐并将它们移动到容器的左下角?因为当我使用 div 进行包装时,它们会消失

4

2 回答 2

2

这很容易,你可以用div container这样的方式包裹点

<!--Column Dots -->
<div class="dot-container">
  <span class="dot selected-dot"></span>
  <span class="dot"></span>
  <span class="dot"></span>
</div>

并为容器设置如下样式

.dot-container{
width: 15px;
display: flex;
flex-direction:column;
align-items:center;
}

并获得更好的造型。给dot班级一些amrgin之类的margin: 3px 0;

这是一个代码笔: https ://codepen.io/shammlo/pen/QWKggNX ?editors=1100

于 2020-12-18T14:19:19.933 回答
2

第一:将点包裹在容器中。我在课堂上使用了一个部分:.dot-wrapper. 第二:给包装器一个width: min-content;. 这样,它只会与选定的点一样宽。3rd:为了使点居中,给它们一个左右边距 auto ;

.dot {
  border-radius: 50%;
  height: 12px;
  width: 12px;
  background: linear-gradient(90deg, #76b3fe, #8680e4);
  margin: 5px auto;
}

.selected-dot {
  height: 20px;
  width: 20px;
  background: #97cdfe;
}

.dot-wrapper {
  width: min-content;
}
<section class="slider-bg-1 d-flex align-items-end">
  <div class="container">
    <div class="row justify-content-center">
      <div class="col-lg-5 d-flex flex-column justify-content-center pt-4 pt-lg-0 order-2 order-lg-1">
        <h1 class="head-font-size">Choose a powerful design for your Start-up</h1>
        <h6 claas="caption-text-color">Get your freebie template now</h6>
        <div class="d-lg-flex">
          <div class="mt-5"><button class="my-btn" type="submit">Discover</button></div>
        </div>
      </div>
      <div class="col-lg-5 col-md-12 col-sm-12 order-1 order-lg-2 d-flex justify-content-center">
        <img src="Assets/home-slider/slider-m-1.png" class="img-fluid img-slider" alt="">
      </div>
    </div>
  </div>

  <section class="dot-wrapper">
    <div class="dot selected-dot"></div>
    <div class="dot"></div>
    <div class="dot"></div>
  </section>
</section>

于 2020-12-18T14:21:41.907 回答