我在大多數瀏覽器(即ff,chrome,safari)上都有很奇怪的問題。 下面是示例代碼:保證金頂部:100%獲得父寬度值...奇怪
<!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>
當改變#aDiv寬度,然後#bDiv邊距將與相同的值而改變。 我不知道它是如何可能的,高度達到寬度。無論如何,也許你可以向我解釋發生了什麼事?
最好的問候;)
D.
我當時的工作完全不同,但是因爲瀏覽器並不總是按預期工作,所以我測試了完全隨機的屬性,作爲邊緣頂端:100%有點傻。我在(垂直)margin-top/margin-bottom和(horizontal)width之間得到了奇怪的相關性。正如你所說,相當無用;) –
不幸的是,它符合標準,但祝你好運。 –
什麼樣的白癡把這個標準..這是......幾乎令人難以置信的愚蠢,基於水平值的垂直百分比。 – Noishe