Home  >  Article  >  Web Front-end  >  关于css中div内部的定位问题_html/css_WEB-ITnose

关于css中div内部的定位问题_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:08:041075browse

请问一下,怎样才能定位div内部的一些东西呀,比如我在div内部有一个ul,可是我想要控制ul在div的中间靠下,要怎么来设置?在线求解答


回复讨论(解决方案)

用 margin padding
和absolute定位都可以

margin和padding不是要指定具体的数值什么的吗,有类似的像设置center什么的方法吗

一般就写固定数值,也可以用js动态设定。

我一般都用下面这两个属性,
margin,外边界:
控制围绕边框 的边距大小。其中包含4个属性:margin-top控制上边距的宽度、margin-right控制右边距的宽度、margin-bottom控制下边距的宽度、margin-left控制左边距的宽度。
padding,内边界:
确定围绕块元素的空格填充数量,其中包含4个属性“padding-top控制上留白的宽度、padding-right控制右留白的宽度、padding-bottom控制下留白宽度、padding-left控制左留白的宽度。

另外,还要注意:position属性的absolute、relative和static;设置了这个属性会对margin和padding有影响。

用 margin padding
和absolute定位都可以

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn