top

您所在的位置:网站首页 top和bottom的用法 top

top

2023-06-28 23:55| 来源: 网络整理| 查看: 265

top样式属性定义了定位元素的上外边距边界与其包含块上边界之间的偏移,非定位元素设置此属性无效。

/* values */ top: 3px; top: 2.4em; /* 参照于包含块高度的百分比 */ top: 10%; /* Keyword value */ top: auto; /* Global values */ top: inherit; top: initial; top: unset;

top的效果取决于元素的position属性:

当position设置为absolute或fixed时,top属性指定了定位元素上外边距边界与其包含块上边界之间的偏移。 当position设置为relative时,top属性指定了元素的上边界离开其正常位置的偏移。 当position设置为sticky时,如果元素在 viewport 里面,top属性的效果和 position 为relative等同;如果元素在 viewport 外面,top属性的效果和 position 为fixed等同。 当position设置为static时,top属性无效。

当top和bottom同时指定时,并且 height没有被指定或者指定为auto的时候,top和bottom 都会生效,在其他情况下,如果 height被限制,则top属性会优先设置,bottom属性则会被忽略。

初始值auto适用元素positioned elements是否是继承属性否Percentagesrefer to the height of the containing block计算值if specified as a length, the corresponding absolute length; if specified as a percentage, the specified value; otherwise, autoAnimation typea length, percentage or calc();


【本文地址】


今日新闻


推荐新闻


    CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3