如何在box属性中设置轮播图片的尺寸?

时间:2018-09-18 02:06:29

标签: javascript html css bootstrap-4

如何在盒子中清晰地显示旋转木马图片。图片也不应在盒子内溢出。当ı尝试使用该代码时,图片从框中溢出,并且用户无法清晰地看到这些轮播图片,那么ı该如何解决该问题?

.kutu {
width: 1490px;
height: 645px;
margin: 0;
padding: 0;
background: rgba(0,0,0,0.4);
position: absolute;
margin-top: 40px;

}


.altkutu {

width: 1000px;
height: 350px;
margin-left: 280px;
background-color: red;
overflow: auto;
}
<div class="kutu">

      <div class="altkutu">
        <div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
          <ol class="carousel-indicators">
            <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
            <li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
            <li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
          </ol>
          <div class="carousel-inner" role="listbox" style="max-width:1000px; max-height:350px;">
            <div class="carousel-item active">
              <img class="d-block w-100" src="aaa.jpg" alt="First slide" style="overflow:hidden;" >
            </div>
            <div class="carousel-item">
              <img class="d-block w-100" src="aaaa.jpg" alt="Second slide">
            </div>
            <div class="carousel-item">
              <img class="d-block w-100" src="aaaaa.jpg" alt="Third slide">
            </div>
          </div>
          <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
            <span class="carousel-control-prev-icon" aria-hidden="true"></span>
            <span class="sr-only">Previous</span>
          </a>
          <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
            <span class="carousel-control-next-icon" aria-hidden="true"></span>
            <span class="sr-only">Next</span>
          </a>
        </div>


      </div>


    </div>

1 个答案:

答案 0 :(得分:0)

在此行代码中:

<div class="carousel-item active">
   <img class="d-block w-100" src="aaa.jpg" alt="First slide" style="overflow:hidden;" >
</div>

因为它已放在img中,所以它无法正常运行。尝试将overflow:hidden;放在其包装上:div .carousel-item

所以它看起来像这样:

<div class="carousel-item active" style="overflow:hidden;" >
   <img class="d-block w-100" src="aaa.jpg" alt="First slide" >
</div>