【问题标题】:CSS - Why is my content not scrolling?CSS - 为什么我的内容不滚动?
【发布时间】:2015-07-11 05:50:26
【问题描述】:

更新 2 我刚刚从下面修复了“编辑 2”,bodySection div 的内容在 navLogo/navElements div 的顶部向上滚动。位置:relative 是罪魁祸首,现在我在 bodySection 类上没有位置(因此,据我所知,默认为静态),它按预期工作。

我仍然认为我的代码中的一些东西有点古怪(更新的小提琴和嵌入下面的代码)。例如,为了让所有东西都按我想要的那样排列,我有一些非常非常奇怪的宽度属性;

left、mid 和 rightSection 都设置为 30% 宽度,因此它们占用了大约 1/3 的可用空间。这很有意义。

bodySection 类的宽度为 98%,左边距为 1%,右边距为 2%。为什么两边不是 100% 的宽度和 1% 的填充?它位于 100% 宽度的“容器”div 内。我认为它会继承父 div 的边界。

.navElements 类的宽度为 95%,如果我将其增加到 100%,它会表现出各种有趣的行为,将文本推离可视屏幕。这是为什么呢?

.navLogo 类的宽度为 100%,甚至 img 也被标记为 100%,但我可以告诉你,你看到的大小并不是实际图像大小的 100%。它我想要的大小,但不是 100%,这是为什么呢?

即使在 32 英寸显示器(我的笔记本电脑外接显示器)上,我也看到一个水平滚动条(在底部)。显然我不想要这个。为什么会在这里?

更新小提琴:Fiddle Here

更新代码:

HTML:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <title>Frick Solutions - Technology Consulting for Small Business</title>
    <meta name="keywords" content="HTML,CSS"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <link rel="stylesheet" type="text/css" href="/redesign/css/fricksolutions.css"/>
    <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Roboto">
  </head>
  <body id="home">
  <div class ="container">

  <div class="navLogo">
  <a href="/index.html"><img src="/redesign/img/FrickSolutionsLogoWhite.png" style="height:100%; width:AUTO%;"> </a> <!-- style="max-width:40%;max-height:3%;"></a> -->

  <div class="navElements" align="right">
  <li> <a href="/why.html">Why Us?</a></li> 
  <li> <a href="/smallbusiness.html">Small Business</a></li> 
  <li><a href="/servers.html"> Servers </a></li> 
  <li><a href="/athome.html"> @Home </a> </li> 
  <li> <a href="/contact.html">Contact</a> </li>
  </div> <!--Close navLogo div -->
</div> <!--Close navElements div -->
<div class = "bodySection">
here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>
here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>
here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>
here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>
here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>
here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>
here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>
here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>

<div id = "leftSection">
left text test
</div><!-- Close leftSection -->
<div id = "midSection">
mid text test
</div> <!-- Close midSection -->
<div id = "rightSection">
right text test
</div><!-- Close rightSection -->
</div> <!-- Close bodySection -->
</div> <!-- close container -->

  </body>
</html>

CSS:

body {

  color: black;
  font-family: "Roboto", sans-serif;
  background-color: white;
  margin: 0;  /*use this to ensure left most content goes all the way to border of page */
 }





@media screen and (min-width:30em) { /* used to be 600 px */
  .navLogo
  {
  padding-left: 1%;
  padding-right: 1%;
  position: fixed;
  background-color: #373737;
  width: 100%;
  height: 8%;
   }


   .navElements
   {
   padding-right: 1%;
   font-family: "Roboto", sans-serif;
   background-color: transparent;
   position: absolute;
   bottom: 0px;
   width: 95%;
   padding-bottom: .25%;
    }

    .navElements li
    {
    color: white;
    background-color:transparent;
    display: inline-block;
    padding: 5px 10px 0 0;
     }

     .navElements a { text-deocration: none; }
     a:link 
    {
  color: white 

  }
a:visited 
  {
  color: white 
  }
  a:hover
  {
      color: grey;      
  }


 .bodySection{
 padding-left: 1%;
 padding-right: 2%;
 padding-top: 5%;  /*this is here as a hack to make sure the bodySection div shows up under the navLogo/navElement divs*/
 width: 98%; /*
 position: relative;*/
/* overflow: hidden;*/

  }

 #leftSection, #midSection, #rightSection {
 width: 30%;
 min-width: 30%;
 height: 100px;
 border: 1px solid red;
 margin-left: 10px;
 float:left; 
 padding-left: 1%;
 padding-right: 1%;
 padding-top: 1%;
 padding-bottom: 1%;

 }

  .container{
  width: 100%;
  height: auto;
  /*overflow: hidden;*/ }

 }

更新(减去最初更新的小提琴/代码)已经感谢大家的帮助(不到一个小时,我已经得到了很多好的提示!)。我真的很喜欢这个社区,尽管我很少来这里。我需要改变它!

This is the live version of my redesign -- 编辑 2,我刚刚意识到我现在所拥有的并不能让我点击我放在顶部导航中的任何链接。我认为这是因为 bodySection 重叠(具有 5% 的填充),但很想听听您的想法。

到目前为止,我还没有实施太多建议,但我知道我会的(我只需要彻底了解它们,并且可能还要测试它们)。正如你所看到的,我得到了滚动工作,并通过在 div 上放置 5% 的顶部填充解决了我的“bodySection”问题,所以它总是会下降到导航下方。不幸的是,一旦开始滚动,这并不能阻止 bodySection div 的内容覆盖 navElements 和 navLogo div。

我将删除下面的代码和小提琴(以避免混淆)并在此处发布我更新的代码/小提琴。

原始帖子(减去代码和小提琴链接)

所以我对 CSS 比较陌生(您可能可以从 FIDDLE 中附加的我的 css 文件中看出),但我正在努力改进它。我从事专业的技术咨询,并希望扩展我的技能/服务以包括网页设计(此外,我希望我自己的网站看起来很棒,而无需付费!)。

经过大量的反复试验,我终于让我的顶部导航看起来像我想要的那样。

然后我开始玩内容,我想要像 3x2 表格这样的东西来显示图标和文本。我得到了它按预期工作(一个 3x1,现在只有文本),但在我这样做之后,我决定我需要在标题栏和 css 表之间有一些东西,所以我想我会输入一堆虚拟文本并确保滚动按预期进行。我发现我根本无法使页面的正文滚动。

我已经做了大量的研究来试图解决这个问题,大多数帖子都说“停止使用固定位置”或其他内容。不幸的是,如果我移除我的固定位置,导航栏要么中断,要么不可见。

简而言之,这就是我要寻找的: 我的导航栏需要 100% 的时间出现在屏幕上。我不需要任何疯狂的 jQuery 来将它弹出到某个滚动点的顶部——我只希望它一直在那里。

我的内容需要位于导航栏下方的主 div (bodySection) 中。在那个 bodySection 中,我需要能够嵌入我的 3x1(或 3x2)CSS 表,由 leftSection、midSection、rightSection 组成。

任何清理我的 CSS 并在 HTML 中实现它的提示/提示/技巧将不胜感激。我完全是自学成才(HTML 和 CSS - 在 90 年代中期开始学习 HTML 时还是十几岁的孩子),所以我希望每次在论坛上与人们互动时都能学到很多东西。

【问题讨论】:

  • 您好,感谢您的快速回复。我也一直在玩弄这个,但我想我可能还有其他一些问题,因为如果我在
    之前放置一个
    标签(理论上,关闭“NavElements” div),bodySection 然后上升到标题中,这显然是我不希望发生的。还能是什么?
  • 实际上,进一步审查 - 在 NavElements div 的行尾有一个
    标记(在这篇文章的 HTML 代码块上一直滚动)。为了便于阅读,我已在源代码中对其进行了清理。
  • @Brian 我添加了一个答案让你回到正轨,它可能不是你想要的,但至少它对你来说是一个很好的起点。如果您还有任何问题,请随时提出,我们都在这里互相帮助。
  • 标签: html css web


    【解决方案1】:

    有很多事情是错误的(没有冒犯,我们都必须从某个地方开始)。我将在几个小时内发布修复它的代码并编写一些分析以及一些提示。

    body {
        color: black;
        font-family:"Roboto", sans-serif;
        background-color: white;
        margin: 0;
        /*use this to ensure left most content goes all the way to border of page */
    }
    @media screen and (min-width:30em) {
        /* used to be 600 px */
        .navLogo {
            padding-left: 1%;
            padding-right: 1%;
            position: fixed;
            /* max-width: 40%; */
            background-color: #373737;
            width: 100%;
            height: 30px;
        }
        .navElements {
            padding-right: 5%;
            font-family:"Roboto", sans-serif;
            background-color: transparent;
            position: fixed;
            padding-top: 5px;
            padding-left: 25%;
        }
        .navElements li {
            color: white;
            background-color:transparent;
            display: inline-block;
            padding-left: 15px;
        }
        .navElements a {
            text-deocration: none;
        }
        a:link {
            color: white
        }
        a:visited {
            color: white
        }
        a:hover {
            color: grey;
        }
        #bodySection {
            padding-top: 25px;
            padding-left: 1%;
            padding-right: 2%
            width: 98%;
        }
        #leftSection, #midSection, #rightSection {
            width: 30%;
            min-width: 30%;
            height: 100px;
            /* border: 1px solid red; */
            margin-left: 10px;
            float:left;
            padding-left: 1%;
            padding-right: 1%;
            padding-top: 1%;
            padding-bottom: 1%;
        }
        #container {
            width: 100%;
            height: auto;
        }
    }
    <body id="home">
      <div class ="container">
        <div class="navLogo">
          <a href="/index.html">
            <img src="/img/FrickSolutionsLogoWhite.png" style="height:100%; width:AUTO%;">
          </a>
        </div>
        <div class="navElements" align="right">
          <li><a href="/why.html">Why Us?</a></li>
          <li><a href="/smallbusiness.html">Small Business</a></li>
          <li><a href="/servers.html"> Servers </a></li>
          <li><a href="/athome.html"> @Home </a></li> 
          <li><a href="/contact.html">Contact</a></li>
        </div>
        <div id = "bodySection">
          
          here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>
    here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>
    here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>
    here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>
    here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>
    here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>
    here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>
    here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>here is some text <br>
    
          
          <div id = "leftSection">
      	    <p>left text test</p>
          </div><!-- Close leftSection -->
          <div id = "midSection">
      	    <p>mid text test</p>
          </div> <!-- Close midSection -->
          <div id = "rightSection">
            right text test
          </div><!-- Close rightSection -->
        </div> <!-- Close bodySection -->
      </div>
    </body>

    首先,我建议下载一些 Web 开发工具来帮助了解您的问题。我个人使用 chrome 开发人员工具(预装了 chrome)。右键单击并检查元素以调出大量用于 Web 开发的工具。

    我还建议阅读 W3 Schools 及其庞大的简单示例和教程库。

    好的,小费时间:

    1. 不推荐使用2个body标签。
    2. 不建议在正文标签上使用 ID。
    3. 不推荐使用 ,而是使用 padding 属性。
    4. 为组织目的正确地标记您的元素,并且易于使用 错误发现。

    我注意到你的一个更大的错误是理解“位置”属性选项。对于 99% 的页面,您需要默认的“静态”定位,这会将您的内容相对于其他内容进行放置。对于无论滚动都应保持在视图中的导航和对象,请使用“固定”。很少有情况需要使用“绝对”。

    现在与此网页无关,如果您真的想要漂亮的美学并且不想花费 400 小时开发样式表。我强烈推荐一个响应式 css 模板,例如 bootstrap。

    对于前端 Web 开发的一个很好的(我可能有偏见)示例,我很乐意将您指向我的简历网站。 http://www.brennen-sprimont.com/。右键单击并检查页面以获取其背后的代码。

    更新 1 现在出现在导航栏“上方”的文本。您需要将“bodySection”的 z-index 编辑为较低或将“navLabel”的 z-index 编辑为较高以获得所需的结果。

    更新 2

    @media screen and (min-width: 30em)
    .bodySection {
      padding-left: 1%;
      padding-right: 1%;
      padding-top: 5%;
    }
    

    您的总宽度为 101%,在此之前会出现滚动条。现在当然这 3 个 div 不是完全居中的,这是因为您在父级 (bodySection) 中向左填充 1%,然后在 leftSection div 上留有 10px 的边距。

    navElements 之所以如此奇怪,是因为它位于 navLogo 中,它具有基于 % 的边距,这会使您达到 102%。添加 absolute 会忽略父 div 的边距。

    【讨论】:

    • 那真是太棒了!我最初开始 CSS 只是从其他网站抓取东西,对其进行调整,直到它达到我想要的效果。这个布局,我从头开始 - 我认为(正如你所建议的)我在搞砸它方面做得很好。我将非常感谢任何输入、修复和解释,以帮助我继续学习!
    • 如果您还有任何问题,请随时给我发电子邮件。
    • 我删除了第二个body标签,现在只有。这是我所做的遗留设计遗留下来的,在该设计中,活动页面的背景颜色与导航中的其他页面不同。我确实删除了 nbsp 代码 - 我同意它真的很糟糕,我改为使用填充。我现在正在努力在我的代码中放置适当的选项卡,以使其更具可读性。当我从 CSS 中的 navElements 类中删除 postion: absolute 时,它​​只是从页面的顶部栏中完全删除了我的
    • ,所以我不得不回到 absolute。
  • Bootstrap 绝对是我想尝试的东西,但想先学习 css。我在十几岁的时候就自学了 HTML4,我喜欢学习这些东西是如何工作的。只有这样我才会使用作弊工具和模板,我想我只是一个惩罚的贪吃者:D
  • 在这种情况下使用绝对是正确的。在我的示例中,我在您的 navElements 之前结束了您的 navLogo,因为命名约定对我来说不是最有意义的。当我这样做时,我还向 navElements 添加了“固定”以使它们保持固定。我经常使用的一个技巧是使用属性“背景颜色:红色”设置各种元素,以便在我看不到它们时了解它们在页面上的位置。当您删除绝对时,它会将文本直接放在导航栏下方,导航栏是白色的,因此您看不到它。
  • 【解决方案2】:

    您的容器 div 在您的 HTML 中被标记为一个类,但您在 CSS 中将其定义为一个 ID。请记住,CSS # 用于 ID 和 .用于类

    您提供的小提琴无法正确加载,但您可以让您的 div 中的内容在溢出时滚动。如果您打算将其保留为一个类,您可以尝试

    .container{
    width: 100%;
    height: auto;
    overflow: scroll;
    }
    

    【讨论】:

    • 好提示 - 我仍在学习 CSS 中的 ID 和类。我曾尝试同时使用类和 ID(同时正确更新 CSS 文件中的 . vs # ),但都没有奏效。我还添加了溢出:滚动;到 Container 和 bodySection,但我仍然没有在任何地方滚动。 You can check out the live version here我在这里放了一堆文字只是为了说明我的观点。
    • ^^ 在所有带有“这里是一些文本”的行下面有一个 3x1 CSS 表格,我用一些 div 制作了我将用来存放内容的内容。显然,您现在看不到它们,因为我无法滚动。
    【解决方案3】:

    按照惯例,最好不要有 2 个 body 标签。使用导航元素,您可以将它们设为position:fixed; top:0; left:0;。这通常足以让他们在少数问题上保持领先。

    您将整个内容体嵌套在一个带有 nav-logo 类的 div 中,这可能会导致一些问题。我会仔细检查您是否已关闭所有 div,有时很容易错过这些。

    另外,这是一个关于如何构建网站的松散大纲,使用较新的 html5 语法,通常我从类似的东西开始,然后从那里向上移动,所以我知道它是体面的

    <body> <header> </header> <nav> <ul><li></li></ul> </nav> <section> <article></article> <article></article> <article></article> </section> <footer> </footer> </body>

    【讨论】:

    • 老实说,我想我在某个地方搞砸了。我想我的顶级导航栏是罪魁祸首。我想在左上角有图像/徽标,在右上角(div 的底部)有链接,就像我现在拥有它们一样。我必须在位置、宽度和所有这些方面进行调整,才能获得我想要的顶级导航。无论出于何种原因,当我添加额外的
      标签来关闭 NavLogo div 时,它会搞砸我的整个布局。我的印象是,我应该在使用完每个 div 后立即关闭它,但由于某种原因,它再次对我造成了破坏。
  • 嗯,通过这种方法,您可以快速模拟一些看起来不错的东西,而且真的很干净updated fiddle
  • 好的。所以,我可以关闭 navLogo 标签,然后我会往回滚动。惊人的!但是——当我这样做时,我的 bodySection 直接从页面顶部开始,与我的 navLogo div 重叠。我们快到了,
  • 我说得太早了。关闭 navLogo div 似乎已将我的导航元素从顶部/标题栏中剥离。我确实喜欢 CSS > LI 中的填充 - 比 &nbsp 干净得多 :)。我看到了你的小提琴,我喜欢它。但是,我如何在标题的右侧获取所有这些,然后在标题的左侧放置图像?我希望它们包含在同一个元素中。
  • 其实真的很容易。只是另一个
  • fiddle
  • 【解决方案4】:

    好吧,认为这是一个免费赠品,你有大量的语法错误和非常难以阅读的代码。请记住,在构建您的网站时,空白是您的朋友!我稍微清理了您的代码以使其更易于理解。这是小提琴http://jsfiddle.net/61q7avrL/3/

      <div class ="container">
    
          <div class="navLogo">
              <a href="/index.html"><img src="/img/FrickSolutionsLogoWhite.png" style="height:100%; width:AUTO%;"/></a> 
    
          <div class="navElements" align="right">
              <li><a href="/why.html">Why Us?</a>&nbsp;&nbsp;</li> 
              <li><a href="/smallbusiness.html">Small Business</a> &nbsp;&nbsp;</li> 
              <li><a href="/servers.html"> Servers </a>&nbsp;&nbsp;</li> 
              <li><a href="/athome.html"> @Home </a> &nbsp;&nbsp;</li> 
              <li><a href="/contact.html">Contact</a> </li>
          </div>
          </div>    
      </div>
          <div id = "bodySection">
              <div id = "leftSection">
                        left text test
              </div>
              <div id = "midSection">
                        mid text test
              </div>
              <div id = "rightSection">
                            right text test
              </div> 
           </div>
    

    还有你的 CSS

        body {
        color: black;
        font-family:"Roboto", sans-serif;
        background-color: white;
        margin: 0;
        /*use this to ensure left most content goes all the way to border of page */
    }
    #container {
         width: 1200px;
         height: 1200px;
    }
    
    #bodySection {
            padding-left: 1%;
            padding-right: 2%;
            width: 98%;
    
    }
    #leftSection, #midSection, #rightSection {
            width: 30%;
            height: 400px;
            margin-top: 40px;
            border: 1px solid red;
            margin-left: 1%;
            float:left;
            padding: 1%;
    }
    .navLogo {
            padding-left: 1%;
            padding-right: 1%;
            position: fixed;
            /* max-width: 40%; */
            background-color: #373737;
            width: 100%;
            height: 8%;
    }
    .navElements {
            padding-right: 1%;
            font-family:"Roboto", sans-serif;
            background-color: transparent;
            position: absolute;
            bottom: 0px;
            width: 95%;
            padding-bottom: .25%;
    }
    .navElements li {
            color: white;
            background-color:transparent;
            display: inline-block;
    }
    .navElements a {
            text-deocration: none;
    }
    a:link {
            color: white
    }
    a:visited {
            color: white
    }
    a:hover {
            color: grey;
    }
    
    
    @media screen and (min-width:600px) {
    }
    

    【讨论】:

    • 这看起来很干净。您是否进行了任何“严重”更改,或者只是清理了它?我对此的一个担心是左中和右部分都被导航元素半隐藏。那只是在bodySection div上填充吗?另外,目前无法测试,但会滚动吗?
    • 是的,它确实滚动。但它如何滚动可能是问题所在。我不知道您是否希望导航栏保持静止。所以我只是让它全部可滚动,如果你想保持导航栏在顶部,现在代码已经清理了,这是一个非常容易的改变。
    • 我会建议您使用我的代码。按照您认为合适的方式对其进行编辑,如果您遇到其他问题,请显示您编辑后的我的代码版本,虽然它不是“全部”修复,但它至少可以让其他人更容易阅读并增加您获得更好答案的机会。跨度>
    • 是的,我确实希望顶部导航栏是“固定的”,因此它始终可见。我一定会试试你的代码,但可能要到明天。妻子想去酒厂吃晚饭/喝酒,而且我喝了一些酒后,我往往不会乱搞我的现场直播! :) 多谢了朋友!一旦我处理好它,我将发布编辑过的代码。
    【解决方案5】:

    检查一下

    @media screen and (min-width: 30em)
    .bodySection {
      padding-left: 1%;
      padding-right: 2%;
      padding-top: 5%;
      width: 98%;
      /* position: relative; */
      /* overflow: hidden; */
    }
    

    向左填充 1%,向右填充 2%,宽度为 98%,所以总共 101% 这个错误,

    它需要总计 100%。所以只需 98% 到 97% 。然后滚动会去..

    http://jsfiddle.net/hznpw2dg/3/演示

    【讨论】:

      猜你喜欢
      相关资源
      最近更新 更多
      热门标签