溢出的问题

时间:2012-11-20 16:04:36

标签: css html scroll overflow

我正在使用HTML / CSS网站,主要使用4个div(包装,顶部,菜单和内容),使用居中的布局。

问题是我的#content里面的文字重叠了,我不能强迫它进入div。此外,当我启用div上的滚动并在HTML上禁用它时,滚动只对div不起作用。所以我陷入了重叠的内容,没有向下滚动的选项。

所以,恢复它,我想使用3个固定的div,居中,留下两个边框,并希望我的背景图像不移动。只有内容应在其中滚动。

这是我的CSS代码:

<style type=text/css>

html
{
    overflow: none;
}

head
{

}

body
{
    background-color: #030B12;
}

p
{
    font-family: verdana;
    font-size: 12px;
    color: #FFFFFF;
    text-align: left; 
}

h1
{
    margin-top: 25px;
    font-family: verdana;
    font-size: 16px;
    color: #FFFFFF;
    text-align: center;
}

bg2
{
    position: fixed;
    top: 0;
    left: 0;
}

#wrapper
{
    height: 100%;
    width: 70%; 
    margin: auto;
    background-image: url('bg2.jpg');
    background-position: fixed;
    background-repeat: no-repeat;
}

#top
{
    background-image:url('top.jpg');
    background-repeat: no-repeat;
    background-position: fixed;
    height: 15%;
    width: 100%;
    margin: auto;
}

#menu
{
    height: 60px;
    width: 100%;
    background-image: url('navi_bg.png');
}

#content
{
    overflow: auto;
    display: block;
}

ul
{
    list-style-type: none;
    height: 60px;
    width: 663px;
    margin: auto;
}

ul a
{
    background-image: url(navi_bg_divider.png);
    background-repeat: no-repeat;
    background-position: right;
    padding-right: 22px;
    padding-left: 16px;
    display: block;
    line-height: 60px;
    text-decoration: none;
    font-family: Georgia, "Times New Roman", Times, serif;
    font-size: 21px;
    color: #FFFFFF;
}

ul li
{
    list-style-type: none;
    float: left;

}

ul a:hover
{
    color: #3F5F7B;
}

1 个答案:

答案 0 :(得分:0)

根据可用的内容,我创建了一个我认为正在寻找的布局。将顶级li菜单项置于中心位置存在一些问题,但我相信您可以非常轻松地完成这项工作。如果要仅滚动该区域,则应指定内容区域的高度,并使包装器的背景保持静态。

div#content{
max-height:300px;
overflow-y:scroll;
}

Here is the fiddle

相关问题