当文本大于屏幕时,HTML 滚动条不显示

发布于 2024-12-27 02:58:19 字数 3553 浏览 0 评论 0原文

我正在制作一个使用大量 100% 高度的 DIV 的网站。现在,当文本大于页面时,我希望显示正常的滚动条。不幸的是他们没有。并且在任何地方尝试溢出:自动,情况都会变得越来越糟。

HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
        <title>&lt;PageTitle&gt; | Anga Designs</title>
<!-- Stylesheets -->
        <link rel="stylesheet" type="text/css" href="css/standard.css" />
            <!--[if IE]><link rel="stylesheet" type="text/css" href="css/iefix.css" /><![endif]-->
<!-- /Stylesheets -->
<!-- Scripts -->
<script src="http://code.jquery.com/jquery-1.6.2.min.js" type="text/javascript"></script>
<!-- /Scripts -->
<!-- Meta Tags -->
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<!-- /Meta Tags -->
    </head>
    <body>
<div id="bgstripe"></div>
<div id="outercontainer">
    <div class="leftbar"></div>
    <div id="innercontainer">
        <div id="header">
            <div class="leftbar"></div>
            <div class="innercontent">

            </div>
        </div>
        <div id="content">
            <div>
                <span class="articletitle">Page Title!</span>
                <div class="articletitlebar"></div>
            </div>
            <div class="articletext"><p>
                Put your text here
            </div>
        </div>
    </div>
    <div id="faderight"></div>
</div>
<!-- /container -->
    </body>
</html>

CSS

body, html {
    margin: 0;
    background-color: #eeeeee;
    height: 100%;
    font-family: Tahoma;
    overflow: auto;
}

#bgstripe {
    float: left;
    background-color: #67a7ff;
    width: 50%;
    height: 100%;
}

#faderight {
    position: relative;
    float: right;
    background: url('../images/layout/fade-right.jpg');
    width: 50px;
    height: 100%;
}

#outercontainer {
    position: relative;
    margin: auto;
    width: 1000px;
    height: 100%;
    background-color: #2a5d95;
}

#innercontainer {
    position: fixed;
    float:left;
    width: 950px;
    background-color: #2a5d95;
}

.leftbar {
    position: absolute;
    background: url('../images/layout/leftbar.png');
    width: 50px;
    height: 100%;
}

.innercontent {
    position: relative;
    float: left;
    background-color: #2a5d95;
    height: 100%;
    width: 100%;
    margin-left: 50px;
}

#header {
    position: relative;
    float: left;
    width: 950px;
    height: 200px;
}

#content {
    position: relative;
    float: left;
    width: 100%;
    height: 100%;
}

.articletitle {
    background-color: #003366;
    padding: 10px 10px 10px 60px;
    font-size: 20px;
    font-family: Georgia;
    color: #eeeeee;
}

.articletitlebar {
    position: absolute;
    width: 50px;
    height: 40px;
    background: url('../images/layout/articletitlebar.png');
    margin-top: 10px;
}

.articletext {
    display:block;
    position: absolute;
    margin-left: 70px;
    margin-top: 10px;
    margin-right: 20px;
    margin-bottom: 10px;
    width: 700px;
    min-height: 500px;
}

谁能帮我解决这个问题?我现在完全迷失了.. 在线示例:http://rune.blupfis.nl/wendy/

I am making a website that uses numerous DIVs with a 100% height. Now when the text is bigger than the page I want the normal scrollbars to appear. Unfortunately they don't. and with trying overflow:auto anywehre, it gets worse and worse.

HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
        <title><PageTitle> | Anga Designs</title>
<!-- Stylesheets -->
        <link rel="stylesheet" type="text/css" href="css/standard.css" />
            <!--[if IE]><link rel="stylesheet" type="text/css" href="css/iefix.css" /><![endif]-->
<!-- /Stylesheets -->
<!-- Scripts -->
<script src="http://code.jquery.com/jquery-1.6.2.min.js" type="text/javascript"></script>
<!-- /Scripts -->
<!-- Meta Tags -->
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<!-- /Meta Tags -->
    </head>
    <body>
<div id="bgstripe"></div>
<div id="outercontainer">
    <div class="leftbar"></div>
    <div id="innercontainer">
        <div id="header">
            <div class="leftbar"></div>
            <div class="innercontent">

            </div>
        </div>
        <div id="content">
            <div>
                <span class="articletitle">Page Title!</span>
                <div class="articletitlebar"></div>
            </div>
            <div class="articletext"><p>
                Put your text here
            </div>
        </div>
    </div>
    <div id="faderight"></div>
</div>
<!-- /container -->
    </body>
</html>

CSS

body, html {
    margin: 0;
    background-color: #eeeeee;
    height: 100%;
    font-family: Tahoma;
    overflow: auto;
}

#bgstripe {
    float: left;
    background-color: #67a7ff;
    width: 50%;
    height: 100%;
}

#faderight {
    position: relative;
    float: right;
    background: url('../images/layout/fade-right.jpg');
    width: 50px;
    height: 100%;
}

#outercontainer {
    position: relative;
    margin: auto;
    width: 1000px;
    height: 100%;
    background-color: #2a5d95;
}

#innercontainer {
    position: fixed;
    float:left;
    width: 950px;
    background-color: #2a5d95;
}

.leftbar {
    position: absolute;
    background: url('../images/layout/leftbar.png');
    width: 50px;
    height: 100%;
}

.innercontent {
    position: relative;
    float: left;
    background-color: #2a5d95;
    height: 100%;
    width: 100%;
    margin-left: 50px;
}

#header {
    position: relative;
    float: left;
    width: 950px;
    height: 200px;
}

#content {
    position: relative;
    float: left;
    width: 100%;
    height: 100%;
}

.articletitle {
    background-color: #003366;
    padding: 10px 10px 10px 60px;
    font-size: 20px;
    font-family: Georgia;
    color: #eeeeee;
}

.articletitlebar {
    position: absolute;
    width: 50px;
    height: 40px;
    background: url('../images/layout/articletitlebar.png');
    margin-top: 10px;
}

.articletext {
    display:block;
    position: absolute;
    margin-left: 70px;
    margin-top: 10px;
    margin-right: 20px;
    margin-bottom: 10px;
    width: 700px;
    min-height: 500px;
}

Anyone who can help me with this? I'm totally lost right now..
Online sample: http://rune.blupfis.nl/wendy/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

撩动你心 2025-01-03 02:58:19

#innercontainer 上的position:fixed 即使不是问题的全部,也是问题的一部分。这将像一个绝对定位的元素一样,并从正常流中移除。

position:fixed on #innercontainer is part of the problem, if not the whole issue. That will act like an absolutely positioned element and be removed from the normal flow.

不寐倦长更 2025-01-03 02:58:19

这里的问题是您的 contentdiv 的高度设置为 100%。这使得它膨胀,使其与内容的高度相同。如果您尝试类似这样的操作:

#content {
  float: left;
  height: 500px;
  overflow: auto;
  position: relative;
  width: 100%;
}

您应该看到出现滚动条(但现在可能会丢失一些其他样式)。

The problem here is that the height of your contentdiv is set to 100%. This makes it expand so that it is the same height as its contents. If you try something more like this:

#content {
  float: left;
  height: 500px;
  overflow: auto;
  position: relative;
  width: 100%;
}

you should see the scroll bars appearing (but some other styling may be lost now).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文