在大多数浏览器(即ff,chrome,safari)上,我有一个非常奇怪的"问题".这是示例代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
html{
outline: 1px #0ff solid;
background: rgba(0,255,255,0.1);
}
body{
margin: 0;
padding: 0;
outline: 1px #00f solid;
background: rgba(0,0,255,0.1);
}
#aDiv{
width: 300px;
outline: 1px #f00 solid;
background: rgba(255,0,0,0.2);
}
#bDiv{
margin-top: 100%;
outline: 1px #0f0 solid;
background: rgba(0,255,0,0.1);
}
</style>
</head>
<body>
<div id="aDiv">
<div id="bDiv">
content
</div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
当您更改#aDiv宽度时,#bDiv margin-top将更改为相同的值.我不知道它是如何可能的,高度是宽度.无论如何,也许你可以解释一下我发生了什么?
最好的祝福 ;)
D.