我有position:fixed
<div>
出現在屏幕中間。當有消息時,第二個position:fixed
<div>
放在第一個<div>
的旁邊。CSS position:fixed
我在不同的屏幕尺寸(比如上網本 - 小屏幕)上找到了<div>
的座標。
是否有辦法鎖定彼此的位置?我試圖用一個固定的容器來保存它們,但它們仍然移動。
<div id="container">
<div id="container"></div>
<div id="container"></div>
</div>
編輯:
<div id="wrapper">
<div id="container1"></div>
<div id="container2"></div>
</div>
CSS - 當我改變屏幕尺寸container1和container2的還是移動。
#wrapper {
position: fixed
}
#container1 {
position: fixed
}
#container2 {
position: fixed
}
我需要使用容器1/2 div上的相對定位嗎?
你沒有透露太多的隱瞞你的CSS代碼。 – Sparky
關於您在後續編輯中提出的意見,請參閱下面有關大小和位置的完整答案。另外,還有,你的CSS代碼是什麼?我知道你仍然在隱瞞它,因爲簡單地把'position:fixed'本身放在屏幕上不會居中。 – Sparky