带有页眉和页脚的两列页面布局

发布于 2024-11-08 19:49:24 字数 967 浏览 0 评论 0原文

我正在尝试创建带有页眉和页脚的两列布局,以便左栏、页眉和页脚保持固定,水平和垂直滚动应该出现在自动的主要内容上,我所实现的目的是

<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>Untitled Document</title>

<style type="text/css">

    .header{width:100%;}
    .left_panel{float:left; width:15%; height:500px; overflow:auto;background-color:#99CCFF;}
    .right_panel{float:left; width:85%; height:500px; overflow:auto;background-color:#FFFFCC;}
    .footer:{width:100%;margin-top:5px;}


</style>
</head>

<body>
    <div class="header">

        <h3>HEADER!</h3>

    </div>
    <div class="left_panel">Left Panel</div>
    <div class="right_panel">
            <p class="grey">

        Main content
        </p>


    </div>

    <div style=""></div>

    <div class="footer"><h3 align="center">Footer!</h3></div>

</body>
</html>

I am trying to create two column layout with header and footer so that left bar, header and footer remains fixed and horizontal and vertical scroll should appear on main content on auto what i have achieved so for is

<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>Untitled Document</title>

<style type="text/css">

    .header{width:100%;}
    .left_panel{float:left; width:15%; height:500px; overflow:auto;background-color:#99CCFF;}
    .right_panel{float:left; width:85%; height:500px; overflow:auto;background-color:#FFFFCC;}
    .footer:{width:100%;margin-top:5px;}


</style>
</head>

<body>
    <div class="header">

        <h3>HEADER!</h3>

    </div>
    <div class="left_panel">Left Panel</div>
    <div class="right_panel">
            <p class="grey">

        Main content
        </p>


    </div>

    <div style=""></div>

    <div class="footer"><h3 align="center">Footer!</h3></div>

</body>
</html>

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

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

发布评论

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

评论(2

む无字情书 2024-11-15 19:49:24

在页脚之前添加空 div clear: 都在样式中。

Before the footer add in the empty div clear: both in the styling.

忘羡 2024-11-15 19:49:24

在这种情况下,您确实不需要 clear: Both 因为左侧导航和主要内容具有相同的高度,但请注意左侧导航也有 overflow: auto< /code> 并且它还会显示该块的滚动(如果那里有很多内容)。

主要内容已经有了卷轴,取决于内容量

我做了这个例子http://jsfiddle.net/jackJoe/pADyc/,减少了高度主要内容,以便您可以看到效果。

编辑:为了让您不要感到困惑,我更改了主要内容,使其具有原始高度,并且有很多内容,它显然显示垂直滚动: http://jsfiddle.net/jackJoe/pADyc/1/

现在你可能会问有关水平滚动的问题......好吧,它只会显示如果内容水平溢出,这种情况只会发生在块元素上(宽度较宽的 div、图像、无法换行的文本,您会得到图片)。

In this case you really won't need the clear: both because both the left nav and the main content have the same height, but mind you that the left nav also has overflow: auto and it will also show the scroll for that block (if you have a lot of content there).

The main content already has the scrolls, it depends on the amount of content.

I made this example http://jsfiddle.net/jackJoe/pADyc/, reducing the height of the main content so that you can see the effect.

EDIT: Just so you don't be confused, I changed the main content so that it has the original height, and with a lot of content, it obviously shows the vertical scrolls: http://jsfiddle.net/jackJoe/pADyc/1/

And now you may ask about the horizontal scrolls... Well, it will just show them if the content overflows horizontally, which only happens with block elements (div with a wider width, images, text that cannot be wrapped, you get the picture).

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