這是令人難以置信的奇怪,但檢查出以下的HTML和CSS。這工作得很好,只要我離開表和tableWrapper作爲爲他們定義的ID的元素css視覺差異ids和類
如果我試圖讓他們的類(改變#在.css中)和改變ID爲類的HTML元素然後圓形類不再包含在tableWrapper中(它們延伸到它的邊界之外)。我真的非常驚訝,因爲我從來沒有想過某件事是一個id還是一個班級可能會影響佈局,但我發現IE10和Google Chrome v25都會發生這種情況。
我不是在尋找解決這個特定問題的方法。我正在尋找理解並希望能夠鏈接到一些w3c文檔,解釋它爲什麼會發生,以及我對此有什麼期望。
<html>
<head>
<style>
.circle{
background-color:red;
border-radius:50%;
height:90%;
width:100%;
colore:white;
top:7%;
position:absolute;
left:0px;
}
.innerCircle{
border-radius:50%;
background-color:white;
position:absolute;
top:12%;
z-index:2;
left:5%;
height:80%;
width:90%;
}
#navBar{
background-color:black;
color:white;
width:100%;
height:7%;
}
#table{
height:550px;
border:solid 1px black ;
width:500px;
position:absolute;
top:0px;
}
#tableWrapper{
height:90%;
width:100%;
}
</style>
</head>
<body>
<div id="table">
<div id="navBar">
Room info
</div>
<div id="tableWrapper">
<div class="circle">
</div>
<div class="innerCircle">
</div>
</div>
</div>
<input type="text" id="xval" style="float:right" />
<input type="text" id="yval" style="float:right" />
</body>
</html>
你能提供jsFiddle的例子嗎?我很確定這是關於CSS優先系統的。 – MarcinJuraszek 2013-03-09 21:07:04
對我沒有改變http://jsfiddle.net/B6b7s/ – 2013-03-09 21:07:46