<分区>
我正在制作一个网站,但我希望它在我更改窗口大小时调整大小。
所以我做的一切都是百分比。
谁能解释为什么它仍然表现得如此奇怪,以及如何解决它?
最佳答案
不要对 left 、 right 、 top 和 bottom 使用边距,而只使用 left 、 right 、 top 和 bottom 属性
看看我做了什么
<!DOCTYPE html>
<head>
<style type="text/css">
html {
height: 100%;
background-color: #272C34;
margin: 0%;
padding: 0%;
}
body{
height: 100%;
position: static;
margin: 0%;
padding: 0%;
}
#whitetop {
width: 100%;
height: 4%;
position: absolute;
background-color: #E8E8E7;
top: 10%;
left: 0%;
right: 0%;
bottom: -10%;
padding: 0%;
z-index: 1;
}
#whitebot {
width: 100%;
height: 30%;
position: absolute;
background-color: #E8E8E7;
top: 32%;
left: 0%;
right: 0%;
bottom: -32%;
padding: 0%;
z-index: 1;
}
#earth {
width: 100%;
height: 20%;
position: absolute;
top: 10%;
left: 0%;
right: 0%;
bottom: -10%;
z-index: 0;
}
</style>
<link type="text/css" rel="stylesheet" href="stylesheet.css"/>
<title>Home</title>
</head>
<body>
<div id="whitetop">
</div>
<div id="whitebot">
</div>
<img src="earth2.jpg"/ id="earth">
</body>
</html>
关于HTML/CSS - 奇怪的调整大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27878408/