1

我为我的页面创建了这个 .css 文件:

#content-box, #header-box, #menu-box, #footer-box
{
    background-color:#084B8A;
    color:#FFFFFF;
}

#content-box
{
    display:block;
    width:auto;
    min-height:205px;
    border-radius: 10px;
    -moz-border-radius: 10px;
    margin:1px;
    padding:5px;
}

#menu-box
{
    position:fixed;
    display:block;
    width:auto;
    height:205px;
    border-radius: 10px;
    -moz-border-radius: 10px;
    margin:1px;
    padding:5px;
}

#footer-box
{
    display:block;
    width:auto;
    height:20px;
    border-radius: 10px;
    -moz-border-radius: 10px;
    margin:0px;
    padding:0.5px 5px;
    text-align:right;
}

#header-box
{
    display:block;
    width:auto;
    height:20px;
    border-radius: 10px;
    -moz-border-radius: 10px;
    margin:0px;
    padding:0.5px 5px;
    text-align:left;
}

当我向下/向上滚动页面但不工作时,我想#menu-box 移动。这是页面的排列:

#header-box
---------------------------------------
         |#
         |c
#menu-box|o
         |n
         |t
         |e
         |n
         |t
         |-
         |b
         |o
         |x
---------------------------------------
                            #footer-box

在每个 div(#header-box, #menu-box, #content_box, #footer-box) 我添加信息(在 #menu-box 我添加一个 css 垂直下拉菜单)。

编辑:这是我的 HTML 代码,我认为问题出在表格标签上:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="ro">
<head>
<title>...</title>
</head>
<body>
<table border="1" width="100%"><tr><td><div id='header-box'>Bine ai venit
</div></td></tr></table>
<table border="1" width="100%">
<tr><td style="width:200px; height:205px;"><div id='menu-box'><?php include("nav.php"); ?></div></td>
<td><div id='content-box'>
<?php // content ?>
</div></td></tr></table>
<table border="0" width="100%"><tr><td><div id='footer-box'>Creat de ...</div></td></tr></table>
</body>
</html>

(正常边框设置为 0 但现在,因为我设置为 1 我看不到我的#menu-box)

@Andrew:我知道我需要一个长页面,并且我在#content-box 中列出了表格。

4

2 回答 2

2

我在这里创建了您的代码的 jsfiddle:http: //jsfiddle.net/cXmhS/

它似乎工作。您需要有更多的内容才能使菜单随滚动条一起移动。

为了让它更好地工作,我改变了你的min-height:1005px;

于 2013-04-12T11:00:02.513 回答
0

即使我看到类似的答案,我也尝试创建自己的示例。对我来说,最好为自己设置宽度,#menu-box因为没有办法向左浮动。如果菜单框具有自动宽度,即使定义边距也无济于事。

我的解决方案是这样的:http: //jsfiddle.net/6sg3v/

定义width:#menu-box和适当margin-left:#content-box

于 2013-04-12T12:02:41.217 回答