The difference between top and margin-top

1. Top, bottom, left, and right are absolute positioning, and position must be set to absolute.

 

The margin series of settings are relative positioning.

 

Note: If you use top, etc., and position is not set to absolute, the setting will not work.

 

2. Under the premise of absolute positioning, this absolute positioning is the absolute positioning of the parent element relative to the body or position:relative.

 

     The relative positioning of margin refers to the positioning relative to adjacent elements.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326137201&siteId=291194637
top