我想适合我的网站浏览器我试过这个,当我尝试“宽度= 100% 高度= 100%”身体的CSS它确实,当我试图与容器的div它有点消失意味着背景颜色是没有看到如何用CSS调整100%的浏览器高度和宽度?
这是HTML:
<html>
<head>
<title>Untitled</title>
<link href="css/stylesheet1.css" rel="stylesheet" type="text/css"/>
<link rel="icon" type="image/x-icon" href="images/favicon.ico" /></head>
</head>
<body>
<div id="container">
<div id="header">
<div class="logo">
<div id="logo">Logo</span></div>
</div><!--Logo-->
<div class="search-bar">Search BAr</div>
</div>
</div>
</body>
</html>
这是CSS
body{
width:100%;
height:100%;
margin: 0;
background:#CCC;
}
#container{
width:100%;
height:100%;
margin:0 auto;
background:#000;
}
#header{
width:100%;
height:12%;
float:left;
background:#F00;
}
.logo{
width:50%;
height:100%;
float:left;
background:#0F0;
}
.search-bar{
width:50%;
height:100%;
float:left;
color:#FFF;
font-family: 'century gothic';
text-align:center;
margin-top:20px;
}
#logo
{
width:100%;
height:100%;
float:left;
font-size:48px;
color:#FFF;
font-family: 'century gothic';
text-align:center;
margin-top:20px;
}
我麻烦帮我plzzz
你能举个例子吗? – Radioactive
@Radioactive检查这个http://jsfiddle.net/tilwinjoy/3F3T5/请注意,我已经给出了HTML,身体和容器的高度..如果你删除任何高度属性,其中的'%'中有高度的子元素没有任何身高.. –
我应该改变什么? 身体宽度:100%; 身高:100%; margin:0; 背景:#CCC; } #容器{ 宽度:100%; 身高:100%; margin:0 auto; 背景:#000; } – Radioactive