我想不通这个。我有一组简单的 div,带有标题、侧边栏和内容区域。标题是全宽的,侧面和内容向左浮动。
我需要侧边栏(用于背景)填充 100% 的页面高度,但是当我检查 chrome 中的元素时,<body>
实际上在页面底部之前很久就结束了,这似乎限制了我的侧边栏的高度。
是什么阻止了<body>
这里填满整个页面?
<body>
<div id="head">
</div>
<div id="sidebar">
<div>
<div id="menu">
<ul>
<li><a href="/dashboard.php"><img src="/img/blank.png" alt="home" id="home_ico">Home</a>
</li>
<li class="admin"><a><img src="/img/blank.png" alt="home" id="users_ico">Users</a>
<ul class="submenu" style="display: none;">
<li><a href="/users">Manage users</a></li>
<li><a href="/users/add.php">Add a user</a></li>
</ul>
</li>
<li class=""><a><img src="/img/blank.png" alt="home" id="clients_ico">Clients</a>
<ul class="submenu" style="display: none;">
<li><a href="/client_orgs">Manage clients</a></li>
<li><a href="/client_orgs/add.php" class="admin">Add a client</a></li>
</ul>
</li>
<li class=""><a><img src="/img/blank.png" alt="home" id="projects_ico">Projects</a>
<ul class="submenu" style="display: none;">
<li><a href="/projects">Manage projects</a></li>
<li><a href="/projects/add.php" class="admin">Create a project</a></li>
<li></li>
<li><a href="/projects/submitted.php" class="admin client">Submitted projects</a></li>
<li><a href="/projects/closed.php" class="admin">Closed projects</a></li>
</ul>
</li>
<li class=""><a href="/my_account"><img src="/img/blank.png" alt="home" id="account_ico">Account</a>
</li>
<li class="active"><a href="/help.php"><img src="/img/blank.png" alt="help" id="help_ico">Help</a>
</li>
</ul>
</div>
</div>
</div>
<div id="body" class="full">
<div id="content">
<!--start block-->
<div class="block">
<h1><img src="/img/blank.png" alt="home" id="help_ico"> Help</h1>
<p>
Curabitur blandit tempus porttitor. Cras mattis consectetur purus sit amet fermentum. Cras mattis consectetur purus sit amet fermentum. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Maecenas faucibus mollis interdum. Maecenas sed diam eget risus varius blandit sit amet non magna.
</p>
</div>
</div>
</body>
CSS:
* {
margin:0;
padding:0;
}
html, body {
height:100%;
font-family:Arial, Helvetica, sans-serif;
font-size: 12px;
line-height: 160%;
position: relative;
background: #000;
}
#sidebar{
width: 200px;
background: #000;
height: 100%;
padding-top: 30px;
-webkit-box-shadow: inset -4px 0px 8px 0px rgba(0, 0, 0, 0.5);
box-shadow: inset -4px 0px 8px 0px rgba(0, 0, 0, 0.5);
float: left;
}
#body{
float: left;
padding: 30px 0 30px 40px;
width: 75%;
}