简体   繁体   English

我如何让 img-fluid 在 Bootstrap Carousel 中工作?

[英]How do i get img-fluid to work in Bootstrap Carousel?

I've been trying to make my images within my carousel responsive by adding the img-fluid tag to them but nothing is working.我一直在尝试通过向它们添加 img-fluid 标签来使我的轮播中的图像具有响应性,但没有任何效果。 I've tried using.important.我试过使用.important。 I've tried using block.我试过使用块。 I am not sure what is preventing the change?我不确定是什么阻止了这种变化? Any suggestions?有什么建议么?

.container{
        
        font-size: 32px;
        font-family: 'Inter', sans-serif;
        position:relative;
        top: 150px;
        right:-15px;
        font-weight: 300;
        width: 1440px;
        letter-spacing: 2px;
        
      
  }
  
 
  
  .item{
      
      
        float:right;
      
     
      
  }
  


<div class="container">
 
<div class="carousel-inner">
  <div class="item active">
    <img class="image img-fluid" src="images/image-tanya.jpg" alt="Tanya" style="height:648px; width:648px;" ><div class="carousel-caption">  
  </div>
    </div>      

  <div class="item ">
    <img class="image img-fluid" src="images/image-john.jpg" alt="John" style="height:648px; width:648px;">
  </div>

style="height:648px; width:648px;" is the culprit是罪魁祸首

The styles defined by the img-fluid class are being overwritten by the inline styles on the img tags in the the HTML.img-fluid class 定义的 styles 将被 styles 中的img标签上的内联 styles 覆盖。 Inline styles always take precedence over those defined in style sheets.内联 styles 始终优先于样式表中定义的那些。 Try removing those inline styles and see what happens:)尝试删除那些内联 styles 看看会发生什么:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM