我有一个盒子,里面写着“测试”。我想让其包含的 div 的宽度为 100%。我不知道该怎么做?下面的 jsFiddle 显示了我想要做什么。我也不想使用任何 Javascript。
JsFiddle:http: //jsfiddle.net/a6ZCR/3/
这是一些代码:
<!DOCTYPE html>
<html>
<head>
<title>Sample Page</title>
<link rel="stylesheet" href="Assets/CSS/Global/Global.css" />
</head>
<body>
<div id="Wrapper">
<div id="Header">
<div id="HeaderInner">
<a href="#" class="HeaderLink Main">Link</a>
<a href="#" class="HeaderLink Main">Link</a>
<a href="#" class="HeaderLink Main">Link</a>
<a href="#" class="HeaderLink Main">Link</a>
<a href="#" class="HeaderLink Side">Log In</a>
<a href="#" class="HeaderLink Side">Register</a>
</div>
</div>
<div id="Menu">
</div>
<div id="Body">
<div id="BodyPadding">
<div class="BasicBox">
Test
</div>
</div>
</div>
</div>
</body>
</html>
CSS:
/* Layout */
html, body, #Wrapper {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
background-color: #F4F4F4;
font-family: Arial, Helvetica, sans-serif;
font-size: 15px;
}
#Header {
position: fixed;
top: 0;
left: 0;
display: block;
width: 100%;
min-width: 965px;
height: 50px;
background-color: #333;
z-index: 1000;
}
#HeaderInner {
display: block;
width: 965px;
height: 50px;
margin: 0 auto;
padding: 0;
}
#Content {
position: absolute;
top: 50px;
left: 0;
display: block;
width: 100%;
min-width: 965px;
height: 100%;
}
#Menu {
position: fixed;
top: 50px;
left: 0;
width: 220px;
height: auto;
min-height: 100%;
background-color: #FFF;
border-right: 1px solid #DDD;
}
#Body {
position: absolute;
top: 50px;
left: 220px;
width: auto;
height: auto;
min-height: 100%;
}
#BodyPadding {
padding: 30px;
}
/* Layout End */
/* Links */
.HeaderLink.Main {
float: left;
margin: 0;
padding: 0 35px;
color: #E1E1E1;
text-align: center;
font-weight: bold;
text-decoration: none;
line-height: 50px;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
transition: color .2s ease-in-out;
-moz-transition: color .2s ease-in-out;
-webkit-transition: color .2s ease-in-out;
}
.HeaderLink.Main:hover {
color: #FFF;
border-top: 4px solid #DC3522;
line-height: 43px;
}
.HeaderLink.Side {
float: right;
margin: 0;
padding: 0 20px;
color: #E1E1E1;
text-align: center;
text-decoration: none;
line-height: 50px;
transition: color .2s ease-in-out;
-moz-transition: color .2s ease-in-out;
-webkit-transition: color .2s ease-in-out;
}
.HeaderLink.Side:hover {
color: #FFF;
}
/* Links End */
/* Objects */
.BasicBox {
width: 100%;
height: auto;
margin: 0;
padding: 20px;
background-color: #FFF;
border-bottom: 4px solid #DDD;
}
/* Objects End */