css中定位position、偏移top,bottom,left,right和高宽度设置问题

css

1.定位问题position

position:absolute;其包含块为设置的最近的position:relative;或者是position:absolute;的元素。

2.偏移属性offset

top、right、bottom、left应用于定位元素。

偏移属性定义了距离包含块相应边的偏移,而不是距离包含块左上角的偏移。

3.width height属性

元素有外边距、边框、内边距时,设置了top、right、bottom、left之后,height和width设置为多大都不起作用。而无的话,则起作用。

top、right、bottom、left的值设置为正值时,元素向内收缩,设置为负值时,向外扩张。

4.限制高度和宽度min-width、min-height、max-width、max-height

用于非替换行内元素和表元素以外的所有元素。

windows平台的IE7之前都不支持这些属性。

5.clip:rect(top,right,bottom,left);

应用于绝对定位元素。

6.元素绝对定位时,如果除bottom外某个任意偏移属性设置为auto时,会有一种特殊的行为。

猜你喜欢

转载自blog.csdn.net/qq_40095973/article/details/80666394