设置绝对位置和边距 [英] Set position absolute and margin
本文介绍了设置绝对位置和边距的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将元素的位置
设置为 absolute
,并具有底部
,但似乎 margin-bottom
没有效果。
I would like to set an element's position
to absolute
and have a margin-bottom
, but it seems that the margin-bottom
doesn't have an effect.
HTML:
<div id='container'></div>
CSS:
#container {
border: 1px solid red;
position: absolute;
top: 0px;
right: 0px;
width: 300px;
margin-bottom: 50px; // this line isn't working
}
推荐答案
p>你希望 margin-bottom
在你的元素位于顶部时做什么?
What are you expecting margin-bottom
to do when your element is positioned by its top side?
code> margin-bottom 将只对绝对
定位元素执行任何操作。 top 属性。
margin-bottom
will only do anything to an absolute
ly-positioned element if the element has no top
property.
这篇关于设置绝对位置和边距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文