Bootstrap页面未占全宽

时间:2015-06-08 11:22:57

标签: html css twitter-bootstrap

即使在桌面视图上,页面的宽度也不是100%,我使用bootstrap来设计它在www.kenyabuzz.com/mobile上托管的页面html

    {% load markup thumbnail mptt_tags kb %}
    <!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">
        <meta name="description" content="">
        <meta name="author" content="">

        <title>{% block title %}{% if page.title %}{{ page.title }} |{% endif %} Kenya Buzz{% endblock %}</title>

        <!-- Bootstrap Core CSS -->
        <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet">


        <!-- Custom CSS -->
        <link href="{{ STATIC_URL }}kb/css/shop-homepage.css" rel="stylesheet">
        <link href="{{ STATIC_URL }}kb/css/buzz.css" rel="stylesheet">

        <!-- HTML5 Shim and Respond.js 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/libs/html5shiv/3.7.0/html5shiv.js"></script>
            <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>

        <![endif]-->
        <style>
            .navbar-inverse {
                background-color:black;
                }

            .bottom-margin {
                margin-bottom: 20px;
                }


            hr {
                display: block;
                height: 2px;
                border: 0;
                border-top: 1px solid #ccc;
                margin: 1em 0;
                padding: 0;
                background-color:red;
                }
        </style>
    </head>

    <body id="home">

        <!-- Navigation -->
        <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
            <div class="container-fluid">
                <!-- Brand and toggle get grouped for better mobile display -->
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a href="/accounts/signup/"><span class="glyphicon glyphicon-user"></span></a>
                    <a class="navbar-brand" href="/"><img src="{{ STATIC_URL }}kb/img/kenya-buzz-logo.gif" alt=""></a>

                </div>

                <!-- Collect the nav links, forms, and other content for toggling -->
                <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                    <ul class="nav navbar-nav">
                        {% recursetree top_menu %}
                          <li class="stackAuto">
                            <a href="{% if node.url_override %}{{ node.url_override }}{% else %}{{ node.get_absolute_url }}{% endif %}" title="{{ node.title }}" class="stackContent{% if node.id == page.id or node.id == page.parent.id %} current{% endif %}">
                              {{ node.name }}
                            </a>
                          </li>
                          {% endrecursetree %}
                    </ul>
                </div>
                <!-- /.navbar-collapse -->

            </div>
            <!-- /.container -->
        </nav>

        <!-- Page Content -->


<div class="container-fluid">
            <div id="footer">
            <div id="footing" class="row">
                <div id="top" class="row">
                    <div class="col-xs-10 ">

                    </div>

                    <div class="top col-xs-2">
                        <a href="#home"><h4 class="align-right">Top</h4></a>
                    </div>
                </div>

                <div class="col-md-12 ">
                    <a href="about-us/about-kenyabuzz"><h4>About Us</h4></a>
                </div>

                <div class="col-md-12">
                    <a href="mailto:info@kenyabuzz.com"><h4>Contact Us</h4></a>
                </div>

                <div class="col-md-12">
                    <a href="/whats-on/create-event/"><h4>Add your event</h4></a>
                </div>

                <div class="col-md-12">
                    <a href="/biz-directory/new-item/"><h4>Add your business</h4></a>
                </div>

                <div class="col-md-12">
                    <div class="row">
                        <div class="col-md-6 col-xs-3">
                            <h4>Follow us</h4>
                        </div>

                        <div class="col-md-6 col-xs-9">
                            <a href="https://twitter.com/KenyaBuzz" target="external"><img src="{{ STATIC_URL }}kb/images/twitter.png" alt=""></a>
                            <a href="https://www.facebook.com/KenyaBuzz"><img src="{{ STATIC_URL }}kb/images/facebook.png" alt=""></a>
                            <a href="www.youtube.com/KenyaBuzz" target="external"><img src="{{ STATIC_URL }}kb/images/youtube.png" alt=""></a>
                            <a href="http://instagram.com/kenyabuzz_" target="external"><img src="{{ STATIC_URL }}kb/images/instagram.png" alt=""></a>
                            <a href="https://plus.google.com/+KenyaBuzzltdNairobi/posts" target="external"><img src="{{ STATIC_URL }}kb/images/googleplus.png" alt=""></a>
                            <a href="http://blog.kenyabuzz.com/" target="external"><img src="{{ STATIC_URL }}kb/images/blog.png" alt=""></a>
                            <a href="http://www.pinterest.com/kenyabuzzltd" target="external"><img src="{{ STATIC_URL }}kb/images/pinterest.png" alt=""></a>
                        </div>
                    </div>

                </div>

                    <div class="row">
                        <div class="col-md-6 col-xs-12">
                        <h4>Sign up for our FREE weekly newsletter</h4>
                        </div>

                        <div class="col-md-6 col-xs-12 margin-top">
                            <form class="form-inline" action="/newsletter/subscribe" method="post">{% csrf_token %}
                              <div class="form-group">
                                  <div class="row">
                                      <div class="col-md-11 col-xs-2">
                                <label for="exampleInputName2">Name</label>
                                    </div>
                                    <div class="col-md-11 col-xs-7">
                                <input type="text" class="form-control" id="exampleInputName2" placeholder="Jane Doe">
                                    </div>
                                </div>
                              </div>
                              <div class="form-group">
                                  <div class="row">
                                      <div class="col-md-11 col-xs-2">
                                <label for="exampleInputEmail2">Email</label>
                                        </div>
                                      <div class="col-md-11 col-xs-8">
                                <input type="email" class="form-control" id="exampleInputEmail2" placeholder="jane.doe@example.com">
                                        </div>
                                    </div>
                              </div>
                              <div class="row">
                                      <div class="col-md-1 col-xs-2">
                                    </div>
                                    <div class="col-md-3 col-xs-2">
                              <button type="submit" class="btn btn-default">Sign me Up</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                </div>
            </div>
        </div>

        </div>
        </div>

        </div>




        <!-- jQuery -->
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>

        <!-- Bootstrap Core JavaScript -->
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>

    </body>

    </html>

我猜测页脚导致错误我只是将其留在页面上。

2 个答案:

答案 0 :(得分:2)

class =“container”对于bootstrap中的每个屏幕大小都有一个固定的宽度(xs,sm,md,lg) class =“container-fluid”扩展以填充可用宽度。

请参阅此链接以获取更多详细信息 https://stackoverflow.com/a/22263969/3464552

答案 1 :(得分:2)

在你的CSS中设置html和body width:100%,然后检查<style> html,body{width:100%} 希望这有帮助