css - 即使使用不同的 id 也无法设计 2 旋转木马

标签 css twitter-bootstrap-3

我是新手,所以请多多包涵。

这是我的片段:

https://liveweave.com/WJav5F

我预期的行为是第一个轮播(id 轮播)具有容器的全宽,没有拉伸(stretch)或任何类型的扭曲。

当前的行为是,如果第二个轮播正确呈现,第一个轮播不会跨越容器的宽度。

我试过像这样使用 id 选择器,但它不起作用:

    #carousel .carousel-inner .item img{

       min-width:100%;

        }

#myCarousel .carousel .item img {   //comment this block and the id carousel  renders correct (no distortion) but break the id myCarousel. 
        max-width: 100%;
        max-height: 100%;
        display: inline-block;
        position: absolute;
        bottom: 0;
        margin: 0 auto;
        left: 0;
        right: 0;
    }

作为@Honzik Kryspin。

#carousel.carousel-inner .item img{

           min-width:100%;

            }

    #myCarousel.carousel .item img {    
            max-width: 100%;
            max-height: 100%;
            display: inline-block;
            position: absolute;
            bottom: 0;
            margin: 0 auto;
            left: 0;
            right: 0;
        }

最佳答案

您的选择器中有空格,这意味着它会在 #myCarousel 中搜索 .carousel。您可能希望第二个选择器为 #myCarousel.carousel .item img

关于css - 即使使用不同的 id 也无法设计 2 旋转木马,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55927152/

相关文章:

twitter-bootstrap - 增加 Bootstrap 导航栏折叠断点,而不影响同一页面上的另一个导航栏

html - megamenu 下拉 Bootstrap 移动崩溃

html - 如何使链接可点击但又不可点击?

javascript - 使用 css、bootstrap、html 的垂直抽屉导航

javascript - jQuery cookie 破坏了我的 CSS 切换输入

html - 我的@import 查询无法正常工作

html - 如何将导航链接放置在右侧并对其应用 scrollspy?

css - 在网格区域中定位元素

javascript - JQuery 根据单击的菜单项添加/删除类

css - Bootstrap3 : Row of tabs or links - when screen narrows, 多余的标签应该流入最右边的下拉标签