bootstrap carousel最大屏幕宽度

时间:2015-06-27 02:53:49

标签: html css twitter-bootstrap carousel

我试图让我的引导旋转木马100%宽度的屏幕,但我一直在我的网站边缘(见截图)

我试图将容器放在最大宽度100%,但它似乎没有做

<body>
<div class="row top" id="home">
  <div class="container">
<nav class="navbar transparent navbar-fixed-top" role="navigation">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="http://www.mariostarks.com">Bob</a>
    </div>
    <div class="navbar-collapse collapse">
      <ul class="nav navbar-nav navbar-right">
        <li><a href="#bio">Meet bob</a></li>
        <li><a href="#bio">Media Gallery</a></li>
        <li><a href="#resume">Accolades</a></li>
        <li><a href="#portfolio">bobs Boards</a></li>
        <li><a href="#bio">Sponsors</a></li>
        <li><a href="#testimonials">Social Media</a></li>
        <li><a href="#contact">Contact</a></li>
      </ul>
    </div><!--/.nav-collapse -->
  </div>
</nav>

   <!-- Carousel
================================================== -->
<div id="myCarousel" class="carousel slide">
  <div class="carousel-inner">
    <div class="item active">
      <img src="http://stwww.surfermag.com/files/2013/06/blowewhite_61813_opbrnd1_14_jj.jpg" alt="">
      <div class="container">
        <div class="carousel-caption">
          <h1>Example headline.</h1>
          <p class="lead">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>
          <a class="btn btn-large btn-primary" href="#">Sign up today</a>
        </div>
      </div>
    </div>
  </div>
</div><!-- /.carousel -->

CSS:

    html,body{
  height:100%;
}
.carousel,.item,.active{
  height:100%;
  max-height: 600px; /*slider height*/
}
.carousel-inner{
  height:100%;
}

.carousel .item img {
    width: 100%; /*img width*/
}
#myCarousel{
  width: 100%;
}

screenshot of site

1 个答案:

答案 0 :(得分:1)

代码的问题在于您拥有container而不是container-fluid.container有一个固定的宽度,虽然你增加了最大宽度,但它限制了旋转木马的限制。

html,
body {
  height: 100%;
}
.carousel,
.item,
.active {
  height: 100%;
  max-height: 600px;
  /*slider height*/
}
.carousel-inner {
  height: 100%;
}
.carousel .item img {
  width: 100%;
  /*img width*/
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />

<div class="row top" id="home">
  <div class="container-fluid">
    <nav class="navbar transparent navbar-fixed-top" role="navigation">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="http://www.mariostarks.com">Bob</a>
        </div>
        <div class="navbar-collapse collapse">
          <ul class="nav navbar-nav navbar-right">
            <li><a href="#bio">Meet bob</a>
            </li>
            <li><a href="#bio">Media Gallery</a>
            </li>
            <li><a href="#resume">Accolades</a>
            </li>
            <li><a href="#portfolio">bobs Boards</a>
            </li>
            <li><a href="#bio">Sponsors</a>
            </li>
            <li><a href="#testimonials">Social Media</a>
            </li>
            <li><a href="#contact">Contact</a>
            </li>
          </ul>
        </div>
        <!--/.nav-collapse -->
      </div>
    </nav>

    <!-- Carousel
================================================== -->
    <div id="myCarousel" class="carousel slide">
      <div class="carousel-inner">
        <div class="item active">
          <img src="http://stwww.surfermag.com/files/2013/06/blowewhite_61813_opbrnd1_14_jj.jpg" alt="">
          <div class="container">
            <div class="carousel-caption">
              <h1>Example headline.</h1>
              <p class="lead">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>
              <a class="btn btn-large btn-primary" href="#">Sign up today</a>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- /.carousel -->