【问题标题】:Why there is no scroll bar in any browser?为什么在任何浏览器中都没有滚动条?
【发布时间】:2014-01-14 08:32:06
【问题描述】:

我自己的页面没有滚动条,无论我做什么,最小化或放大/缩小。它只是没有出现,我尝试过 FF、Chrome 和 IE:都没有。其他网页没问题。这是body元素和css:

<body>
<div class="container" id="page">

CSS 是这样的:

html, body
{
    margin: 0;
    padding: 0;
    color: #555;
    font: normal 10pt Arial,Helvetica,sans-serif;
    background: #EFEFEF;
    overflow: scroll;
}

#page
{
    margin-top: 5px;
    margin-bottom: 5px;
    background: white;
    border: 1px solid #C9E0ED;
}

PS:我正在使用 YII 框架。

更新:

似乎 YII 有一些默认的 css 设置,在 screen.css 中 div container 被提到了 3 次如下:

 .container {width:1250px;margin:0 auto;}
 .container:after 
 {content:"\0020";display:block;height:0;clear:both;visibility:hidden;overflow:hidden;}

.container {display:block;}

我把overflow:hidden改成overflow:scroll还是不行。

【问题讨论】:

  • 你能添加一个 jsfiddle 来重现这个吗? jsfiddle.net
  • 看来你没有显示所有的 HTML 代码... div 有结束标签
    吗?
  • 使用溢出时,您还应该指定元素高度。您是否尝试删除该属性?
  • 你用的是mac吗? >_this 或this
  • 猜猜看,你的代码中的其他地方是否像这样body{overflow:OTHERVALUE !important} 重置了 css?
  • 标签: html css yii


    【解决方案1】:

    为了查看滚动,您必须定义创建滚动的高度和/或宽度。无法查看您是否有内容或您的标记是什么样的——在 HTML 或 body 标记处声明就可以了。

    html, body
    {
        margin: 0;
        padding: 0;
        color: #555;
        font: normal 10pt Arial,Helvetica,sans-serif;
        background: #EFEFEF;
        overflow: scroll;
        height: 1000px; // toggle
        width: 100% // toggle
    
    }
    

    【讨论】:

      【解决方案2】:

      @Evelyn1986 强制一些宽度,它会出现。 试试width:805px; overflow:auto; 然后就是有一些内容,那就是'大'

      【讨论】:

      【解决方案3】:

      请在 body 标记上添加高度..并添加比您在高度属性上给出的值更多的内容....

      body
      {
      margin: 0;
      padding: 0;
      color: #555;
      font: normal 10pt Arial,Helvetica,sans-serif;
      background: #EFEFEF;
      overflow: scroll;
      height:100px;
      }
      

      小提琴:http://jsfiddle.net/nikhilvkd/rVd4M/

      【讨论】:

        猜你喜欢
        • 2011-09-23
        • 2018-08-31
        • 2022-01-13
        • 1970-01-01
        • 2010-09-06
        • 2014-01-15
        • 2011-12-06
        • 2012-12-11
        • 1970-01-01
        相关资源
        最近更新 更多