我正在学Bootstrap.在"入门"菜单上,提供的模板很少.我在玩这个.一个例子是关于固定页脚.我使用了上一个例子中的nav,并希望用固定的页脚来调整它.但是垂直滚动条就要来了.I am looking for element which is causing Vertical Scroll Bar.

以下是HTML:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Bootstrap, from Twitter</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="">
        <meta name="author" content="">

        <!-- Le styles -->
        <link href="css/bootstrap.css" rel="stylesheet">

        <style type="text/css">

            /* Sticky footer styles
            -------------------------------------------------- */

            html,
            body {
                height: 100%;
                /* The html and body elements cannot have any padding or margin. */
            }

            /* Wrapper for page content to push down footer */
            #wrap {
                min-height: 100%;
                height: auto !important;
                height: 100%;
                /* Negative indent footer by it's height */
                margin: 0 auto -60px;
            }

            /* Set the fixed height of the footer here */
            #push,
            #footer {
                height: 60px;
            }
            #footer {
                background-color: #f5f5f5;
            }

            /* Lastly, apply responsive CSS fixes as necessary */
            @media (max-width: 767px) {
                #footer {
                    margin-left: -20px;
                    margin-right: -20px;
                    padding-left: 20px;
                    padding-right: 20px;
                }
            }



            /* Custom page CSS
            -------------------------------------------------- */
            /* Not required for template or sticky footer method. */

            .container {
                width: auto;
                max-width: 680px;
                height: auto;
            }
            .container .credit {
                margin: 20px 0;
            }

            /* Adjust Nav */
            #wrap > .container {
                margin-top: 60px;
            }

        </style>

        <link href="css/bootstrap-responsive.css" rel="stylesheet">

        <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
        <!--[if lt IE 9]>
          <script src="html5shiv.js"></script>
        <![endif]-->

        <!-- Fav and touch icons -->

        <link rel="apple-touch-icon-precomposed" sizes="144x144" href="ico/apple-touch-icon-144-precomposed.png">
        <link rel="apple-touch-icon-precomposed" sizes="114x114" href="ico/apple-touch-icon-114-precomposed.png">
        <link rel="apple-touch-icon-precomposed" sizes="72x72" href="ico/apple-touch-icon-72-precomposed.png">
        <link rel="apple-touch-icon-precomposed" href="ico/apple-touch-icon-57-precomposed.png">
        <link rel="shortcut icon" href="ico/favicon.png">

    </head>

    <body>
        <div id="wrap">
            <div class="navbar navbar-inverse navbar-fixed-top" >
                <div class="navbar-inner">
                    <div class="container">
                        <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                        </button>
                        <a class="brand" href="#">Project name</a>
                        <div class="nav-collapse collapse">
                            <ul class="nav">
                                <li class="active"><a href="#">Home</a></li>
                                <li><a href="#about">About</a></li>
                                <li><a href="#contact">Contact</a></li>
                            </ul>
                        </div><!--/.nav-collapse -->
                    </div>
                </div>
            </div>

            <div class="container">

                <h1>Bootstrap starter template</h1>
                <p>Use this document as a way to quick start any new project.<br> All you get is this message and a barebones HTML document.</p>

            </div> <!-- /container -->
            <div id="push"></div>
        </div> <!-- End Wrap -->

        <div id="footer">
            <div class="container">
                <p class="muted credit">Example courtesy <a href="http://martinbean.co.uk">Martin Bean</a> and <a href="http://ryanfait.com/sticky-footer/">Ryan Fait</a>.</p>
            </div>
        </div>


        <!-- Le javascript
        ================================================== -->
        <!-- Placed at the end of the document so the pages load faster -->
        <script src="../jquery.js"></script>
        <script src="js-ext/bootstrap-transition.js"></script>
        <script src="js-ext/bootstrap-alert.js"></script>
        <script src="js-ext/bootstrap-modal.js"></script>
        <script src="js-ext/bootstrap-dropdown.js"></script>
        <script src="js-ext/bootstrap-scrollspy.js"></script>
        <script src="js-ext/bootstrap-tab.js"></script>
        <script src="js-ext/bootstrap-tooltip.js"></script>
        <script src="js-ext/bootstrap-popover.js"></script>
        <script src="js-ext/bootstrap-button.js"></script>
        <script src="js-ext/bootstrap-collapse.js"></script>
        <script src="js-ext/bootstrap-carousel.js"></script>
        <script src="js-ext/bootstrap-typeahead.js"></script>

    </body>
</html>

我之前遇到过类似的问题,我不记得我是否能找到简单的解决办法.

推荐答案

好的,如果我把集装箱从margin-top改为padding-top来调整导航,那么问题就解决了. 在删除Firebug中的元素后,我找到了解决方案.所以,快速修复问题解决了,但我的问题仍然悬而未决.

如何知道是哪个元素导致了滚动条?有什么窍门吗?

另外,为什么边距顶不起作用,而衬垫顶起作用了呢?

为了清楚我在哪里进行了更改,我添加了修改后的CSS:

   /* Adjust Nav */
    #wrap > .container {
        padding-top: 60px;

    }

Css相关问答推荐

基于子元素的子元素数量的样式元素

如何在Elm中更改视图时添加过渡?

CSS动画与不正确的时间比率

无法瞄准元素

Css-如何隐藏WP管理菜单上没有css类的第4<;li&>

Css扩展搜索栏,如何添加图标结束?

当滚动量较小时,在滚动问题上动画粘性导航

如何使用来自单独模块的代码将自定义标头插入到使用 DT Shiny 呈现的表中?

为什么所有选项卡都没有显示在 React 的 MUI 选项卡组件中?

使用 node-sass 在压缩文件末尾添加 min.css 文件扩展名

使用 CSS 填充悬停过渡的闪烁文本问题

如何将转换应用于相同的元素但处于不同的状态:悬停

如何制作一个div来包装两个浮动div?

如何更改 CSS:JavaScript 中的根 colored颜色 变量

使用 Twitter Bootstrap 使页脚粘在页面底部

如何使内容出现在固定的 DIV 元素下方?

我应该如何组织我的 CSS 文件的内容?

CSS 块格式化上下文是如何工作的?

在 CSS 中结合border-top、border-right、border-left、border-bottom

Rails 中正确的 SCSS assets资源 struct