javascript - 调整大小时如何修复页脚重叠内容

标签 javascript php jquery twitter-bootstrap-3

我的模板有问题。在大屏幕上,它看起来不错,像这样: picture 1

但是当我调整浏览器大小时,内容不会将页脚向下推。这是一张图片:

picture 2

这是我的代码,太长了,请见谅。 索引.php

<!-- Navigation -->
<nav class="navbar navbar-default navbar-fixed-top">
    <div class="container">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header page-scroll">
            <!-- simple code -->
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <!-- simple code -->
        </div>
        <!-- /.navbar-collapse -->
    </div>
    <!-- /.container-fluid -->
</nav>

<!-- Begin page content -->
<header>
    <div class="container">
        <div class="row">
            <div class="col-lg-12">
                <img class="img-responsive" src="<?php echo base_url(); ?>assets/img/simple_img.png" alt="" style="height: 200px;">
                <div class="intro-text">
                    <!-- simple intro -->
                </div>
            </div>
        </div>
    </div>
</header>

<footer class="text-center">
    <div class="footer-above">
        <div class="container">
            <div class="row">
                <div class="footer-col col-md-4">
                    <h3>Location</h3>
                    <p>3481 Melrose Place<br>Beverly Hills, CA 90210</p>
                </div>
                <div class="footer-col col-md-4">
                    <h3>Around the Web</h3>
                    <ul class="list-inline">
                        <!-- some social networks -->
                    </ul>
                </div>
                <div class="footer-col col-md-4">
                    <h3>About Freelancer</h3>
                    <p>Freelance is a free to use, open source Bootstrap theme created by <a href="http://startbootstrap.com">Start Bootstrap</a>.</p>
                </div>
            </div>
        </div>
    </div>
    <div class="footer-below">
        <div class="container">
            <div class="row">
                <div class="col-lg-12">
                    Copyright &copy; Author <?php echo date("Y"); ?>
                </div>
            </div>
        </div>
    </div>
</footer>

这是我的Css,也太长了请见谅(我删除了一些不相关的代码)。

            /* Sticky footer styles
        -------------------------------------------------- */
        html {
          position: relative;
          min-height: 100%;
        }
        body {
          /* Margin bottom by footer height */
          margin-bottom: 60px;
        }
        footer {
          position: absolute;
          bottom: 0;
          width: 100%;
          /* Set the fixed height of the footer here */
          height: 340px;
          background-color: #f5f5f5;
        }


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

        body > .container {
          padding: 60px 15px 0;
        }
        .container .text-muted {
          margin: 20px 0;
        }

        footer > .container {
          padding-right: 15px;
          padding-left: 15px;
        }

        code {
          font-size: 80%;
        }

        /*!
         * Start Bootstrap - Freelancer Bootstrap Theme (http://startbootstrap.com)
         * Code licensed under the Apache License v2.0.
         * For details, see http://www.apache.org/licenses/LICENSE-2.0.
         */

        body {
            overflow-x: hidden;
        }

        header {
            text-align: center;
            color: #fff;
            background: #18bc9c;
        }

        header .container {
            padding-top: 100px;
            padding-bottom: 50px;
        }

        @media(min-width:768px) {
            header .container {
                padding-top: 200px;
                padding-bottom: 69px;
            }

            header .intro-text .name {
                font-size: 4.75em;
            }

            header .intro-text .skills {
                font-size: 1.75em;
            }
        }

        @media(min-width:768px) {
            .navbar-fixed-top {
                padding: 25px 0;
                -webkit-transition: padding .3s;
                -moz-transition: padding .3s;
                transition: padding .3s;
            }

            .navbar-fixed-top .navbar-brand {
                font-size: 2em;
                -webkit-transition: all .3s;
                -moz-transition: all .3s;
                transition: all .3s;
            }

            .navbar-fixed-top.navbar-shrink {
                padding: 10px 0;
            }

            .navbar-fixed-top.navbar-shrink .navbar-brand {
                font-size: 1.5em;
            }
        }

        .navbar {
            text-transform: uppercase;
            font-family: Montserrat,"Helvetica Neue",Helvetica,Arial,sans-serif;
            font-weight: 700;
        }

        .navbar a:focus {
            outline: 0;
        }

        .navbar .navbar-nav {
            letter-spacing: 1px;
        }

        .navbar .navbar-nav li a:focus {
            outline: 0;
        }

        .navbar-default,
        .navbar-inverse {
            border: 0;
            background-color:#233140;
        }

        footer {
            color: #fff;
        }

        footer h3 {
            margin-bottom: 30px;
        }

        footer .footer-above {
            padding-top: 50px;
            background-color: #2c3e50;
        }

        footer .footer-col {
            margin-bottom: 50px;
        }

        footer .footer-below {
            padding: 25px 0;
            background-color: #233140;
        }

我该如何解决这个问题,让页面内容将页脚向下推...在任何尺寸的浏览器中。 感谢您的帮助。

最佳答案

从 css 的 footer 中删除 position:absolute; 似乎有效。如果有 position:absolute 是绝对必要的(请原谅双关语),也许可以考虑使用媒体查询将它设置为绝对在更宽的屏幕尺寸下。

我提供了一个删除了绝对定位的片段,以及可能添加到媒体查询中的片段,这些片段被注释掉了,但只是为了演示。

/* Sticky footer styles
        -------------------------------------------------- */
            html {
              position: relative;
              min-height: 100%;
            }
            body {
              /* Margin bottom by footer height */
              margin-bottom: 60px;
            }
            footer {
              width: 100%;
              /* Set the fixed height of the footer here */
              height: 340px;
              background-color: #f5f5f5;
            }
            /* Custom page CSS
        -------------------------------------------------- */
            /* Not required for template or sticky footer method. */
            body > .container {
              padding: 60px 15px 0;
            }
            .container .text-muted {
              margin: 20px 0;
            }
            footer > .container {
              padding-right: 15px;
              padding-left: 15px;
            }
            code {
              font-size: 80%;
            }
            /*!
         * Start Bootstrap - Freelancer Bootstrap Theme (http://startbootstrap.com)
         * Code licensed under the Apache License v2.0.
         * For details, see http://www.apache.org/licenses/LICENSE-2.0.
         */
            body {
              overflow-x: hidden;
            }
            header {
              text-align: center;
              color: #fff;
              background: #18bc9c;
            }
            header .container {
              padding-top: 100px;
              padding-bottom: 50px;
            }
            @media(min-width:768px) {
              header .container {
                padding-top: 200px;
                padding-bottom: 69px;
              }
              header .intro-text .name {
                font-size: 4.75em;
              }
              header .intro-text .skills {
                font-size: 1.75em;
              }
              /*
                ****Optional****
                footer{
                position:absolute;
                bottom:0px;
                }*/
            }
            @media(min-width:768px) {
              .navbar-fixed-top {
                padding: 25px 0;
                -webkit-transition: padding .3s;
                -moz-transition: padding .3s;
                transition: padding .3s;
              }
              .navbar-fixed-top .navbar-brand {
                font-size: 2em;
                -webkit-transition: all .3s;
                -moz-transition: all .3s;
                transition: all .3s;
              }
              .navbar-fixed-top.navbar-shrink {
                padding: 10px 0;
              }
              .navbar-fixed-top.navbar-shrink .navbar-brand {
                font-size: 1.5em;
              }
            }
            .navbar {
              text-transform: uppercase;
              font-family: Montserrat, "Helvetica Neue", Helvetica, Arial, sans-serif;
              font-weight: 700;
            }
            .navbar a:focus {
              outline: 0;
            }
            .navbar .navbar-nav {
              letter-spacing: 1px;
            }
            .navbar .navbar-nav li a:focus {
              outline: 0;
            }
            .navbar-default,
            .navbar-inverse {
              border: 0;
              background-color: #233140;
            }
            footer {
              color: #fff;
            }
            footer h3 {
              margin-bottom: 30px;
            }
            footer .footer-above {
              padding-top: 50px;
              background-color: #2c3e50;
            }
            footer .footer-col {
              margin-bottom: 50px;
            }
            footer .footer-below {
              padding: 25px 0;
              background-color: #233140;
            }
<!-- Navigation -->
<nav class="navbar navbar-default navbar-fixed-top">
  <div class="container">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header page-scroll">
      <!-- simple code -->
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <!-- simple code -->
    </div>
    <!-- /.navbar-collapse -->
  </div>
  <!-- /.container-fluid -->
</nav>

<!-- Begin page content -->
<header>
  <div class="container">
    <div class="row">
      <div class="col-lg-12">
        <img class="img-responsive" src="<?php echo base_url(); ?>assets/img/simple_img.png" alt="" style="height: 200px;">
        <div class="intro-text">
          <!-- simple intro -->
        </div>
      </div>
    </div>
  </div>
</header>

<footer class="text-center">
  <div class="footer-above">
    <div class="container">
      <div class="row">
        <div class="footer-col col-md-4">
          <h3>Location</h3>
          <p>3481 Melrose Place
            <br>Beverly Hills, CA 90210</p>
        </div>
        <div class="footer-col col-md-4">
          <h3>Around the Web</h3>
          <ul class="list-inline">
            <!-- some social networks -->
          </ul>
        </div>
        <div class="footer-col col-md-4">
          <h3>About Freelancer</h3>
          <p>Freelance is a free to use, open source Bootstrap theme created by <a href="http://startbootstrap.com">Start Bootstrap</a>.</p>
        </div>
      </div>
    </div>
  </div>
  <div class="footer-below">
    <div class="container">
      <div class="row">
        <div class="col-lg-12">
          Copyright &copy; Author
          <?php echo date( "Y"); ?>
        </div>
      </div>
    </div>
  </div>
</footer>

关于javascript - 调整大小时如何修复页脚重叠内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27064287/

相关文章:

javascript - REST API 错误 : Refused to connect to . .. 因为它违反了以下内容安全策略指令:

javascript - 主干 View 作为无序或有序 html 列表的一部分

php - 显示 Woocommerce 存档页面中的可用产品尺寸或尺寸计数

php - 在搜索数据时出现 Elasticsearch 错误请求

php - 如何将 ByteArray(来自 Flash)和一些表单数据发送到 php?

javascript - Uncaught TypeError : $template. get 不是一个函数

javascript - 在 node.js 中使用生成器函数 next() 作为回调

JavaScript `defer` 似乎不起作用

javascript - jQueryUI slider - 固定值(2)

javascript - 如果选中复选框,如何显示或隐藏下拉菜单