【问题标题】:Bootstrap 3 carousel Positioning not workingBootstrap 3轮播定位不起作用
【发布时间】:2016-01-04 14:18:44
【问题描述】:

我为某个网站创建的轮播有问题。轮播在我测试过的所有浏览器中都必须像它一样工作,除了 Mozilla firefox 25.0 版 这是正在发生的事情的图片

如果有人遇到过类似的问题,我想知道他们是如何解决的,谢谢 这是轮播的代码

<!-- Carousel================================================== -->
<div id="Carousel" class="carousel slide">
<!-- Indicators -->
<ol class="carousel-indicators">
  <li data-target="#Carousel" data-slide-to="0" class="active"></li>
  <li data-target="#Carousel" data-slide-to="1"></li>
  <li data-target="#Carousel" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
  <div class="item active">
    <img src="images/slide_pics/1.png" alt="First slide">
    <div class="container">
      <div class="carousel-caption">
        <h1>Example headline.</h1>
        <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
        <p><a class="btn btn-large btn-primary" href="#">Sign up today</a></p>
      </div>
    </div>
  </div>
  <div class="item">
    <img src="images/slide_pics/2.jpg"  alt="Second slide">
    <div class="container">
      <div class="carousel-caption">
        <h1>Another example headline.</h1>
        <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
        <p><a class="btn btn-large btn-primary" href="#">Learn more</a></p>
      </div>
    </div>
  </div>
  <div class="item">
    <img src="images/slide_pics/3.jpg" alt="Third slide">
    <div class="container">
      <div class="carousel-caption">
        <h1>One more for good measure.</h1>
        <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
        <p><a class="btn btn-large btn-primary" href="#">Browse gallery</a></p>
      </div>
    </div>
  </div>
</div>
<a class="left carousel-control" href="#Carousel" data-slide="prev"><span class="glyphicon glyphicon-chevron-left"></span></a>
<a class="right carousel-control" href="#Carousel" data-slide="next"><span class="glyphicon glyphicon-chevron-right"></span></a>

这是我正在使用的 css

/* GLOBAL STYLES
-------------------------------------------------- */
/* Padding below the footer and lighter body text */

body {
padding-bottom: 40px;
color: #5a5a5a;
}



/* CUSTOMIZE THE NAVBAR
-------------------------------------------------- */

/* Special class on .container surrounding .navbar, used for positioning it into place. */
.navbar-wrapper {
position: relative;
z-index: 15;
}


/* CUSTOMIZE THE CAROUSEL
-------------------------------------------------- */

/* Carousel base class */
.carousel {
margin-bottom: 0px;

/* Negative margin to pull up carousel. 90px is roughly margins and height of navbar. */
margin-top: 0px;
}
/* Since positioning the image, we need to help out the caption */
.carousel-caption {
z-index: 10;
}

/* Declare heights because of positioning of img element */
.carousel .item {
height: 400px;
margin-top:-10px;
background-color: #ccc;
}
.carousel-inner > .item > img {
position: absolute;
top: 0;
left: 0;
min-width: 100%;
height: 400px;
}

【问题讨论】:

  • 我已经包含了 html 和 css
  • 太棒了,赞成,因为这是一个更好的问题;)
  • 使用您的 HTML 和 CSS,我看不出普通 FF 和 nightly v27.0a1 之间有什么区别。其他浏览器也不行。不过,它与您的屏幕截图完全不同。 Fiddle
  • 它在其他浏览器上运行良好,但在 mozilla firefox 25.0 版上它仍然给我这个错误。 @李斯特先生。

标签: javascript html css twitter-bootstrap


【解决方案1】:

这里不一定是答案,更多的是调试提示...但是当我遇到这样的问题时,我会在当前 css 之后为每个项目添加 1px 边框,但颜色不同,即

.navbar-wrapper {1px solid purple;}
.carousel {border: 1px solid black;}
.carousel-caption {border: 1px solid yellow;}
.carousel .item {border: 1px solid blue;}
.carousel-inner > .item > img {border: 1px solid red;}

一旦完成,您就会看到“罪魁祸首”是谁——您很可能必须指定 margin-left: 0px;对于该元素,因为 Firefox 似乎错误地从父元素继承了边距。那就拿出疯狂的边界吧!

【讨论】:

  • 非常感谢。我从来没有想过这个。事实证明是左边框导致了 Mozilla Firefox 25.0 中的问题。
【解决方案2】:

我遇到了同样的问题,我发现问题出在轮播上。

.carousel { border: 1px solid black; }

解决了这个问题。

Firefox 20 (Mac) 引导程序 3.1.1

【讨论】:

    【解决方案3】:

    我只用它解决了:

    .carousel {
      border-top: 1px solid #000
    }
    

    【讨论】:

    • 我遇到了同样的问题,这解决了。我想知道为什么吗?为什么顶部边框与元素定位错误有关?
    • 41.0.1版本问题依然存在
    【解决方案4】:
    .carousel {
      border-top: 1px solid transparent;
    }
    

    【讨论】:

      【解决方案5】:
      body {
          overflow-x: hidden;
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-01-05
        • 2013-09-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-01-16
        • 1970-01-01
        相关资源
        最近更新 更多