我对元素定位的痛苦仍在继续:
<div id="container">
<div id="div1"></div>
<div id="div2"></div>
<div id="div3"></div>
</div>
#div1 {
right:0; // what I want - it's right border should be 0px from the parent's right border, regardless of any other div inside.
}
#div2 {
bottom:0; // it's bottom border should be 0px from the parent's bottom border, regardless of any other div inside.
}
#div3 {
margin-left:auto;
margin-right:auto;
// should be on the parent's center, regardless...
}
所以,我希望父母是参考,而不是邻居。
答案 0 :(得分:3)
检查一下:
#container {
position: relative;
}
#div1 {
position: absolute;
right: 0px;
}
#div2 {
position: absolute;
bottom: 0px;
}
#div3 {
margin: 0px auto;
}
但这是你在30秒后可以找到关于div定位的解决方案......
答案 1 :(得分:1)
只需使用CSS
position:relative;
在div1
,div2
,div3
上设置此内容。