【发布时间】:2012-04-04 20:22:38
【问题描述】:
伙计们,如果你测试下面的代码,你可以看到一切都很好,除非你缩小窗口,所以 flash 菜单(红色 div)从页面右侧消失。 好吧,如果窗口小于 900 像素,则有一个水平滚动窗格,到目前为止一切都很好,但它只是滚动页面的内容! 我希望上部也滚动,但只能水平滚动,因为我希望它们被固定(始终保持在网站顶部)...
有什么建议吗?我从谷歌尝试了很多东西,但没有一个是正确的 4 我......
thx & g.r.王牌
html:
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Titel</title>
<link href="main.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="div_page" align="center">
// page content goes here
</div>
<div id="div_menu">
<img src="img/logo.png" alt="<Logo>" style="position:absolute; top:0px; left:20px; width:225px; height:150px;">
<div id="div_flash"></div>
</div>
</body>
</html>
css:
@charset "utf-8";
body {
padding:0px;
margin:0px;
}
#div_menu {
position:fixed;
top:0px; right:0px; left:0px;
width:100%; height:40px;
min-width:800px;
overflow:visible;
background-image:url(img/menu.png);
background-position:top left;
background-attachment:fixed;
background-repeat:no-repeat;
background-size:100% 40px;
background-color:#333;
}
#div_flash {
position:absolute;
top:0px; left:250px;
width:500px; height:150px;
background-color:#F00;
}
#div_page {
position:absolute;
top:40px; right:0px;left:0px;
min-width:800px; min-height:500px;
}
【问题讨论】:
-
你想知道什么?如果你按照我描述的那样测试代码,你就会明白我的意思......
-
实际上我测试了代码,我看不到你说的内容在移动
-
您是否将窗口的大小调整为小于宽度:800 像素和高度:600 像素?首先,你应该在 div_page 中添加一些
blabla
,因为如果页面内没有任何内容可以滚动,则页面可能不会滚动 ^^跨度>
..... -
你能详细告诉我你需要的布局吗?
-
好吧,我只是想让顶部的菜单处于固定位置,所以只有页面内容在滚动......问题是:如果 div 设置为 position:fixed,你不能滚动到右边,如果菜单的右边部分在窗口之外...
标签: css scroll css-position