<html>
<head>
<title>The testing page</title>
<style type="text/css">
body{
margin: 0px;
padding: 0px;
}
#topbar{
background-color: blue;
width: 100%;
height: 35px;
margin: 0px auto;
}
#logo{
width: 100px;
margin-left: 100px;
float: left;
}
#searchbar{
margin-top: 5px;
margin-left: 10px;
height: 25px;
width: 400px;
float: left;
border-radius: 2px;
border: 1px #000 solid;
padding: 5px 5px 5px 5px;
position: absolute;
z-index: 5;
}
#leftmenu{
float: left;
width: 300px;
background-color: green;
height: 500px;
margin-left: 25px;
margin-top: 10px;
}
#main{
background-color: yellowgreen;
height: 100%;
width: 500px;
position: relative;
margin-top: 10px;
margin-left: 335px;
padding: 16px;
}
h1{
margin: 0px
}
p{
margin: 0px
}
</style>
</head>
<body>
<div id="topbar">
<img id="logo" src="images/explogo.png">
<input id="searchbar" type="text" placeholder="Search">
</div>
<div id="leftmenu">
</div>
<div id="main">
<h1>Fixed Top Menu</h1>
<h2>Scroll this page to see the effect</h2>
<h2>The navigation bar will stay at the top of the page while scrolling</h2>
<p>Some text some text some text some text..</p>
<p>Some text some text some text some text..</p>
<p>Some text some text some text some text..</p>
<p>Some text some text some text some text..</p>
<p>Some text some text some text some text..</p>
<p>Some text some text some text some text..</p>
<p>Some text some text some text some text..</p>
<p>Some text some text some text some text..</p>
<p>Some text some text some text some text..</p>
<p>Some text some text some text some text..</p>
<p>Some text some text some text some text..</p>
<p>Some text some text some text some text..</p>
<p>Some text some text some text some text..</p>
<p>Some text some text some text some text..</p>
<p>Some text some text some text some text..</p>
<p>Some text some text some text some text..</p>
<p>Some text some text some text some text..</p>
<p>Some text some text some text some text..</p>
<p>Some text some text some text some text..</p>
<p>Some text some text some text some text..</p>
<h1>Fixed Top Menu</h1>
<h2>Scroll this page to see the effect</h2>
<h2>The navigation bar will stay at the top of the page while scrolling</h2>
</div>
</body>
</html>
我一直在学习CSS和HTML,但是我是一个新手,我知道有些人会笑。但是,如何在左侧,右侧菜单和导航栏保持静止的同时使主要部分滚动?我已经在主要部分中添加了一些文本,但是当我向左滚动菜单时,导航栏和主要滚动会一起
答案 0 :(得分:0)
如果将#main更改为以下内容,则会出现滚动条。那是你要的吗?这些更改使您的身高成为静态值,然后添加了滚动溢出。对于您的特定示例,我还必须调整宽度。
r’resources\treasure.png’