在旋转木马幻灯片之间移动时的白色背景

White background when moving between carousel slides

我的 html 网站有问题。我目前正在使用 Bootstrap-5。当我在网站中使用轮播更改幻灯片时,不断出现白色空白。我该如何处理这个问题?

这是我的代码!

HTML

<!doctype html>
<html lang="kr">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
    <link rel="stylesheet" href="./style.css">
    <title>P&P</title>
  </head>
  <body>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" crossorigin="anonymous"></script>
    <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
  </body>

  <nav class="navbar navbar-expand-lg">
    <div class="container">
      <a class="navbar-brand" href="#">P & P</a>
      <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarScroll" aria-controls="navbarScroll" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>
      <div class="collapse navbar-collapse" id="navbarScroll">
        <ul class="navbar-nav m-auto my-2 my-lg-0">
          <li class="nav-item dropdown">
                <a class="nav-link dropdown-toggle" href="#" id="navbarScrollingDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                  Some Script
                </a>
                <ul class="dropdown-menu" aria-labelledby="navbarScrollingDropdown">
                  <li><a class="dropdown-item" href="#">Some script</a></li>
                  <li><a class="dropdown-item" href="#">Some script</a></li>
                  <li><a class="dropdown-item" href="#">Some script</a></li>
                </ul>
          </li>  
          <li class="nav-item">
            <a class="nav-link active"href="#">Some script</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#">Some script</a>
          </li>
          
          <li class="nav-item">
            <a class="nav-link" href="#">Some script</a>
          </li>
        </ul>

      </div>
    </div>
  </nav>


 
  <div id="carouselExampleCaptions" class="carousel slide" data-ride="carousel">
    <ol class="carousel-indicators">
      <li data-target="#carouselExampleCaptions" data-slide-to="0" class="active"></li>
      <li data-target="#carouselExampleCaptions" data-slide-to="1"></li>
      <li data-target="#carouselExampleCaptions" data-slide-to="2"></li>
    </ol>
    <div class="carousel-inner">
      <div class="carousel-item active">
        <img src="lemon_wp.jpg" class="d-block w-100" alt="...">
        <div class="carousel-caption d-none d-md-block">
          <h5>Some script<br>Some script</h5>
          <h6><br>Some script</h6>

        </div>
      </div>
      <div class="carousel-item">
        <img src="lemon_wp.jpg" class="d-block w-100" alt="...">
        <div class="carousel-caption d-none d-md-block">
          <h5>Some script<br></h5>
          <h6>Some script<br>Other script</h6>
        </div>
      </div>

    </div>
    <a class="carousel-control-prev" href="#carouselExampleCaptions" role="button" data-slide="prev">
      <span class="carousel-control-prev-icon" aria-hidden="true"></span>
    </a>
    <a class="carousel-control-next" href="#carouselExampleCaptions" role="button" data-slide="next">
      <span class="carousel-control-next-icon" aria-hidden="true"></span>

    </a>
  </div>
  
  <section class="babies">
      <div class="container py-5">
          <div class="row py-5">
              <class class="col-lg-5">
                  <h1></h1>
              </class>
          </div>
      </div>
  </section>

</html>

CSS

*{
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

.navbar-brand{
    font-size: 2rem;
    color: black;
}
.navbar-brand:hober{
    color: black;
}
.nav-link{
    margin-right: 10px;
    margin-left: 10px;
    color: black;
    text-transform: uppercase;
}
.nav-link:hover{
    color: black;
}
.main{
    background-color: lemonchiffon;
    background-size: cover;
    height: 100vh;
    width: 100%;
    background-position: 50% 50%;
}
.main h1{
    font-size: 4rem;
    font-weight: 700;
    /*fontfamiliy*/
}
.absolute-div {
    position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
}
.item {
    position:relative;
}
.carousel-item{
    height: 100vh;
    min-height: 300px;
    background: no-repeat scroll center scroll;
    -webkit-background-size: cover;
    background-size: cover;
}
.carousel-item::before{
    content: "";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
}
.carousel-caption{
    bottom: 35%;
    padding-left: 100px;
    padding-right: 100px;
    color: black;
}
.carousel-caption h5{
    font-size: 100px;
    font-weight: 700;
}

.carousel-caption h6{
    font-size: 60px;
    font-weight: 600;
}

.carousel-control-next-icon:after{
   content: '>';
   font-size: 55px;
   color: black;
 }
  
.carousel-control-prev-icon:after {
   content: '<';
   font-size: 55px;
   color: black;
 }
.carousel {
    width:100% !important; 
    overflow: hidden !important; 
    right:0 !important; 
}
.carousel-inner{
    overflow:visible
} 

我真的找不到我的代码中的问题。 我使用的轮播示例来自 bootstrap 官方网站。

我不知道为什么会这样,但你可以试试这个它适用于你的代码

 <div id="carouselExampleControls" class="carousel slide" data-bs-ride="carousel">
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img src="a.lpg" class="d-block w-100" alt="...">
      <div class="carousel-caption d-none d-md-block">
          <h5>Some script<br>Some script</h5>
          <h6><br>Some script</h6>

        </div>
    </div>
    <div class="carousel-item">
      <img src="b.jpg" class="d-block w-100" alt="...">
      <div class="carousel-caption d-none d-md-block">
          <h5>Some script<br>Some script</h5>
          <h6><br>Some script</h6>

        </div>
    </div>
    <div class="carousel-item">
      <img src="c.jpg" class="d-block w-100" alt="...">
      <div class="carousel-caption d-none d-md-block">
          <h5>Some script<br>Some script</h5>
          <h6><br>Some script</h6>

        </div>
    </div>
  </div>
  <button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleControls" data-bs-slide="prev">
    <span class="carousel-control-prev-icon" aria-hidden="true"></span>
    <span class="visually-hidden">Previous</span>
  </button>
  <button class="carousel-control-next" type="button" data-bs-target="#carouselExampleControls" data-bs-slide="next">
    <span class="carousel-control-next-icon" aria-hidden="true"></span>
    <span class="visually-hidden">Next</span>
  </button>
</div>

并且您的 css 上不需要此代码,您在 bootstrap

中默认拥有它
.carousel-control-next-icon:after{
   content: '>';
   font-size: 55px;
   color: black;
 }
  
.carousel-control-prev-icon:after {
   content: '<';
   font-size: 55px;
   color: black;
 }
 

亲爱的,当您添加旋转木马滑块时,它会自动将滑块移动的白色箭头附加到左右其旋转木马默认部分 css 并且在您的 css 中,您还通过给定的代码添加了箭头以下

.carousel-control-next-icon:after{
   content: '>';
   font-size: 55px;
   color: black;
 }

.carousel-control-prev-icon:after {
   content: '<';
   font-size: 55px;
   color: black;
}

试着评论它,这样它就会删除黑色箭头 或使用 carousal javacript 方法去除黑色箭头