Bootstrap Div不使用响应式图像创建可滚动区域

时间:2016-07-23 08:47:27

标签: html css twitter-bootstrap twitter-bootstrap-3

我正在努力让一个画廊部分与bootstrap一起工作。由于某种原因,scrollspy不会为图像创建可滚动区域。图像只是重叠边框并一直运行到页面底部。

    <!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title></title>

    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/gallery.css" rel="stylesheet">
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>

        <div class="container-fluid" id="container-fluid">
            <div class="container">

                <nav class="navbar navbar-default">
                  <div class="container-fluid">
                    <div class="navbar-header">
                      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span> 
                      </button>
                      <a href="home-page.html" class="navbar-left" id="nav-brand"><img src="images/sugar-logo.png" style="width:100%;height:100%;"></a>
                    </div>
                    <div class="collapse navbar-collapse" id="myNavbar">
                      <ul class="nav navbar-nav">

                        <li ><a href="home-page.html">Home</a></li>
                        <li ><a href="experience.html">Experience</a></li>
                        <li class="active"><a href="#">Gallery</a></li>
                      </ul>
                      <ul class="nav navbar-nav navbar-right">
                        <li><a href="#"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li>
                        <li><a href="#"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>

                      </ul>
                    </div>
                  </div>
                </nav>

                <div class="row" id="content" >
                    <div class="col-md-4" id="text">
                        <h3>What to Expect</h3>
                    </div>
                    <div class="col-md-8" id="slides" data-spy="scroll" data-offset="0" >           
                        <div class="col-md-4">
                             <img src="images/01.jpg" class="img-responsive" alt="" width="100%" height="100%">
                        </div>
                        <div class="col-md-4">
                             <img src="images/02.jpg" class="img-responsive" alt="" width="100%" height="100%">
                        </div>
                        <div class="col-md-4">
                             <img src="images/03.jpg" class="img-responsive" alt="" width="100%" height="100%">
                        </div>
                        <div class="col-md-4">
                             <img src="images/04.jpg" class="img-responsive" alt="" width="100%" height="100%">
                        </div>
                        <div class="col-md-4">
                             <img src="images/05.jpg" class="img-responsive" alt="" width="100%" height="100%">
                        </div>
                        <div class="col-md-4">
                             <img src="images/06.jpg" class="img-responsive" alt="" width="100%" height="100%">
                        </div>
                        <div class="col-md-4">
                             <img src="images/07.jpg" class="img-responsive" alt="" width="100%" height="100%">
                        </div>
                        <div class="col-md-4">
                             <img src="images/08.jpg" class="img-responsive" alt="" width="100%" height="100%">
                        </div>
                        <div class="col-md-4">
                             <img src="images/09.jpg" class="img-responsive" alt="" width="100%" height="100%">
                        </div>
                        <div class="col-md-4">
                             <img src="images/10.jpg" class="img-responsive" alt="" width="100%" height="100%">
                        </div>
                        <div class="col-md-4">
                             <img src="images/11.jpg" class="img-responsive" alt="" width="100%" height="100%">
                        </div>
                        <div class="col-md-4">
                             <img src="images/12.jpg" class="img-responsive" alt="" width="100%" height="100%">
                        </div>
                        <div class="col-md-4">
                             <img src="images/13.jpg" class="img-responsive" alt="" width="100%" height="100%">
                        </div>
                        <div class="col-md-4">
                             <img src="images/14.jpg" class="img-responsive" alt="" width="100%" height="100%">
                        </div>
                        <div class="col-md-4">
                             <img src="images/15.jpg" class="img-responsive" alt="" width="100%" height="100%">
                        </div>
                        <div class="col-md-4">
                             <img src="images/16.jpg" class="img-responsive" alt="" width="100%" height="100%">
                        </div>
                        <div class="col-md-4">
                             <img src="images/17.jpg" class="img-responsive" alt="" width="100%" height="100%">
                        </div>
                        <div class="col-md-4">
                             <img src="images/18.jpg" class="img-responsive" alt="" width="100%" height="100%">
                        </div>
                        <div class="col-md-4">
                             <img src="images/19.jpg" class="img-responsive" alt="" width="100%" height="100%">
                        </div>
                        <div class="col-md-4">
                             <img src="images/20.jpg" class="img-responsive" alt="" width="100%" height="100%">
                        </div>
                        <div class="col-md-4">
                             <img src="images/21.jpg" class="img-responsive" alt="" width="100%" height="100%">
                        </div>
                        <div class="col-md-4">
                             <img src="images/22.jpg" class="img-responsive" alt="" width="100%" height="100%">
                        </div>
                        <div class="col-md-4">
                             <img src="images/23.jpg" class="img-responsive" alt="" width="100%" height="100%">
                        </div>
                    </div>
                </div>
            </div>
        </div>

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>
  </body>
</html>

CSS代码

body{
    padding: 0px;
    margin: 0px;
}
#container-fluid{
    background-image: url("background/bground-main.png");
    background-position: cover;
    z-index: -1;
}
.container{
    width: 80%;
    margin-top: 50px;
    margin-bottom: 100px;
    background-color: white;
    border-radius: 25px;
    border: 2px solid white;
    padding: 20px; 
    height:auto;
    background-color: #e6e6e6;
}
#nav-brand{
    width: auto;
    height: 80px;
}
.navbar-default {
  background-color: #bfdcf2;
  border-color: #000000;
}
.navbar-default .navbar-brand {
  color: #000000;
}
.navbar-default .navbar-brand:hover,
.navbar-default .navbar-brand:focus {
  color: #4ab648;
}
.navbar-default .navbar-text {
  color: #000000;
}
.navbar-default .navbar-nav > li > a {
  color: #000000;
  height: 60px;
  padding: 30px 15px 50px 15px;
  font-size: 125%;

}
.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus {
  color: #4ab648;
}
.navbar-default .navbar-nav > .active > a,
.navbar-default .navbar-nav > .active > a:hover,
.navbar-default .navbar-nav > .active > a:focus {
  color: #000000;
  background-color: #4ab648;
}
.navbar-default .navbar-nav > .open > a,
.navbar-default .navbar-nav > .open > a:hover,
.navbar-default .navbar-nav > .open > a:focus {
  color: #4ab648;
  background-color: #000000;
}
.navbar-default .navbar-toggle {
  border-color: #000000;
}
.navbar-default .navbar-toggle:hover,
.navbar-default .navbar-toggle:focus {
  background-color: #000000;
}
.navbar-default .navbar-toggle .icon-bar {
  background-color: #000000;
}
.navbar-default .navbar-collapse,
.navbar-default .navbar-form {
  border-color: #000000;
}
.navbar-default .navbar-link {
  color: #000000;
}
.navbar-default .navbar-link:hover {
  color: #4ab648;
}
#text{
    height: auto;
    padding-bottom: 20px;
}
#text h3{
    text-transform:uppercase;
    font-size: 200%;
    text-align:center;
}
#slides{
  height: 600px;
  max-height: 600px;
}
#slides .col-md-4{
  padding: 5px;
}

有人有任何想法吗? https://postimg.org/image/84h2tgkq9/

2 个答案:

答案 0 :(得分:1)

对于滚动,您可以使用overflow:scroll;

请检查here

答案 1 :(得分:1)

只需将样式overflow: auto;添加到#slides即可。见here

  

overflow属性指定是否剪切内容,渲染滚动条或仅在溢出其块级容器时显示内容。

我想你也想将样式overflow: hidden;添加到.container。