ITeye博客

top、margin-top的区别

it1990eye0920 · 2018-04-04 15:07 · CSS · Web前端 · Markdown

1、top、bottom、left、right是绝对定位,必须设置position为absolute。

 

margin一系列设置是相对定位。

 

注意:如果用top等,而position未设置为absolute,那设置是不起作用的。

 

2、top这些在绝对定位的前提下,这个绝对定位,是相对body  或者  position:relative的父级元素的绝对定位。

 

     margin的相对定位,是指相对相邻元素的定位。

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。