定位div在底部
Positioning div at the bottom
好的,我的问题是这样的。如何在不使用 margin-top 的情况下将 child 元素定位为主 div 中的另一个 div?请检查我的屏幕截图以更好地理解我的问题。
我的主要 div 是 177px x 177px。我的 child div 是 100px x 25px 我需要在主 div 的底部向右浮动大约 20px margin-bottom.
谢谢,
理查德.
使用绝对定位。将您的主要 div 定位到 relative,然后将您的内部 div 定位到 absolute,如下所示:
.main-div {
position: relative;
height: 177px;
width: 177px;
}
.inner-div {
position: absolute;
right: 0;
bottom: 20px;
width: 100px;
height: 20px;
}
好的,我的问题是这样的。如何在不使用 margin-top 的情况下将 child 元素定位为主 div 中的另一个 div?请检查我的屏幕截图以更好地理解我的问题。
我的主要 div 是 177px x 177px。我的 child div 是 100px x 25px 我需要在主 div 的底部向右浮动大约 20px margin-bottom.
谢谢,
理查德.
使用绝对定位。将您的主要 div 定位到 relative,然后将您的内部 div 定位到 absolute,如下所示:
.main-div {
position: relative;
height: 177px;
width: 177px;
}
.inner-div {
position: absolute;
right: 0;
bottom: 20px;
width: 100px;
height: 20px;
}