@media(min-width:768px)崩溃无法正常工作

时间:2016-08-03 05:26:10

标签: html css twitter-bootstrap media

感谢您阅读和回答我的问题。我的问题是@media(min-width:768px)无效,而不是显示切换按钮,它只显示桌面样式。我想做的是让它看起来像移动设计。这是我的HTML代码:

<!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">
<title>Internship Exercise 1</title>
<link href="css/custom.css" rel="stylesheet">
<link href="css/bootstrap.css" rel="stylesheet">

</head>
<body><!--Navbar start-->
  <nav class="navbar navbar-default navbar-static-top" role="navigation">
    <div class="container">
      <div class="navbar-header clearfix">
          <a class="navbar-brand" href="#"><img src="img/logo.png" alt="logo" width="60%"></a>
          <a class="navbar-toggle pull-right" data-toggle="collapse" data-target="#collapsed-navigation">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </a>
      </div>
      <div class="navbar-collapse collapse " id="collapsed-navigation">
          <ul class="nav navbar-nav navbar-right">
            <li><a href="#">Home</a></li>
            <li><a href="#">About</a></li>
            <li><a href="#">Services</a></li>
            <li><a href="#">Pricing</a></li>
            <li><a href="#">Contact</a></li>
          </ul>
      </div><!-- /.navbar-collapse -->
    </div>
  </nav>
<!--First middle start-->
<div class="container">
  <div class="row">
    <div class="col-sm-12">
    <img src="img/topimg.jpg" alt="image" width="100%">   
    </div>
  </div>
    <div class="row">
        <div class="col-md-8">
          <div>
            <h2>Heading 1</h2>
            <div class="standard-lorem">
              <h4>The standard Lorem Ipsum passage, used since the 1500s</h4>
              <p>
              Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.
              </p>
            </div>
            <div class="section">
              <h4>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC</h4>

              <p>"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"

              "At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."
              </p>
            </div>
          <div>

            <h4>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC</h4>

            <p>"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat." Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent blandit imperdiet lorem, iaculis elementum ex placerat eu. Curabitur vitae augue placerat, rutrum nisl pretium, tincidunt ex. Aliquam tristique porttitor libero vel commodo. Morbi porttitor neque eget semper placerat. 
            </p>
          </div>
            <a class="btn btn-default" href="#">More Info</a>
          </div>
        </div>
        <!-- /.col-md-4 -->
        <div class="col-md-4">
            <div>
              <h2>Heading2</h2>
              <div class="standard-lorem">
              <h4>The standard Lorem Ipsum passage, used since the 1500s</h4>
              <p>
              Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.
              </p>
              </div>

              <div>
              <h4>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC</h4>

              <p>"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"

              "At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod
              </p>
              </div>
            <a class="btn btn-default" href="#">More Info</a>
          </div>
        </div>
        <!-- /.col-md-4 -->
    </div>
<!--End first middle-->
<!--Start second middle-->
      <div class="row">
        <div class="secuppermiddle col-sm-4">
          <div class="middlebckg secuppermiddleinside col-sm-12">
            <span class="align"><h2><small class="text-muted">500X500</small></h2></span>
          </div>
        </div>
        <div class="secuppermiddle col-sm-4">
          <div class="middlebckg secuppermiddleinside col-sm-12">
            <span class="align"><h2><small class="text-muted">400X400</small></h2></span>
          </div>
        </div>
        <div class="secuppermiddle col-sm-4">
          <div class="middlebckg secuppermiddleinside">
            <span class="align"><h2><small class="text-muted">300X300</small></h2></span>
          </div>
        </div>
      </div>
    </div>
  </div>
  </div><!--End second middle-->
  <div class="row">
  <div class="belowmiddle col-sm-12">
    <div class="container">
        <div class="row">
          <div class="secuppermiddle col-sm-4">
            <div class="middlebckg secuppermiddleinside col-sm-12">
              <span class="align"><h2><small class="text-muted">200X200</small></h2></span>
            </div>
          </div>
          <div class="secuppermiddle col-sm-4">
            <div class="middlebckg secuppermiddleinside col-sm-12">
              <span class="align"><h2><small class="text-muted">100X100</small></h2></span>
            </div>
          </div>
          <div class="secuppermiddle col-sm-4">
            <div class="middlebckg secuppermiddleinside col-sm-12">
              <span class="align"><h2><small class="text-muted">50X50</small></h2></span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
    <div class="container">
      <div class="row">
        <div class="beforefooter col-md-12">
            <div id="myCarousel" class="carousel slide" data-ride="carousel">
              <!-- Indicators -->
                <ol class="carousel-indicators">
                  <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
                  <li data-target="#myCarousel" data-slide-to="1"></li>
                  <li data-target="#myCarousel" data-slide-to="2"></li>
                </ol>

              <!-- Wrapper for slides -->
                <div class="carousel-inner" role="listbox">
                  <div class="item active">
                    <img src="img/slide1.jpg" alt="slide1">
                  </div>

                  <div class="item">
                    <img src="img/slide2.jpg" alt="slide2">
                  </div>

                  <div class="item">
                    <img src="img/slide3.jpg" alt="slide3">
                  </div>
                </div>

                <!-- Left and right controls -->
                <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
                  <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
                  <span class="sr-only">Previous</span>
                </a>
                <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
                  <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
                  <span class="sr-only">Next</span>
                </a>
              </div>
            </div>
        </div>
      </div>
      <!-- Footer -->
      <div class="container footer">
        <footer>
          <div >
            <div class="col-lg-12">
              <p>Copyright &copy; Mikz Website 2016</p>
            </div>
          </div>
        </footer>
    </div>    
  </div>
  <script src="js/jquery.min.js"></script>
  <script src="js/bootstrap.min.js"></script>
</body>

这是我的css代码:

.navbar-static-top {
        min-height: 120px!important;
        }
        .navbar-default .navbar-nav > li > a {
          color: #ffffff;
        }
        .navbar-default .navbar-nav > li > a:hover,
        .navbar-default .navbar-nav > li > a:focus{
          border-bottom:3px solid white!important;
          background: transparent!important;
          margin-bottom: -3px;
        }

        html, body {
            overflow-x:hidden 
        }
        .firstuppermiddle{
            border:0px solid black;
            height: 890px;
            margin-top: 30px;
        }
        .firstuppermiddleinside{
            height: 880px;
        }

        .standard-lorem{
            margin-bottom: 60px;
            margin-top:60px;
        }
        .section{
            margin-bottom: 60px;
        }

        .middle-margin{
            margin-left: 10px;
        }
        .col-1-width{
            width: 5px;
        }
        .secuppermiddle{
            border:0px solid black;
            margin-top: 20px;
        }
        .secuppermiddleinside{
            height: 300px;
            line-height: 280px;
            text-align: center;
        }
        .align{
              display: inline-block;
              vertical-align: middle;

              line-height: normal;
            }
        .middlebckg{
            background: #f2f2f2;
            margin-top: 20px;
        }
        .secmiddlemargin{
            margin-left: 48px;
        }
        .belowmiddle{
            height:auto;
            background: #401d29;
            margin-top:40px;
            padding-top: 30px;
            padding-bottom:100px;
        }
        .beforefooter{
            margin-top: 20px;

        }
        .footer{
            padding-top: 20px;
        }
        .right.carousel-control, .left.carousel-control {
            opacity: 0;
            filter:alpha(opacity=0); /* IE support */
        }


        @media(max-width: 480px) { 
            .navbar {
                border-radius: 4px;
                min-height: 120px!important;
                 }
            .navbar-brand {
              margin-left:13%;
          }
        }
        @media(min-width: 560px) { 
            .navbar {
                border-radius: 4px;
                min-height: 120px!important;
                 }
            .navbar-brand {
              margin-left:25%;
              margin-bottom: -4%;
            }
            .navbar-toggle{
                margin-top: 70px!important;
            }

        }
        @media(min-width: 768px) { 
            .navbar {
                border-radius: 4px;
                min-height: 120px!important;
                 }
            .navbar-brand {
              margin-left:50%;
              margin-bottom: -4%;
            }
            .navbar-default .navbar-nav > li > a {
            margin-top: 25px;
            }

        }


        @media(min-width : 992px) {
            .navbar {
                border-radius: 4px;
                min-height: 120px!important;
                 }

            .navbar-default .navbar-nav > li > a {
            margin-top: 25px;
            }

            }

0 个答案:

没有答案