css The top attribute specifies the top edge of the element. This attribute defines the offset between the top margin boundary of a positioned element and the upper boundary of its containing block. All major browsers support the top attribute.
How to use the css top attribute?
Function: The top attribute specifies the top edge of the element. This property defines the offset between the top margin boundary of a positioned element and the top boundary of its containing block.
Note:
For static elements, it is auto;
For length values, it is the corresponding absolute length;
For percentage values, it is the specified value;
Otherwise, it is auto.
For relative definition elements, if top and bottom are both auto, their calculated values are both 0;
If one of them is auto, the opposite of the other value is taken;
If neither is auto, bottom will take the opposite number of top value.
Note:
All major browsers support the top attribute. The attribute value "inherit" is not supported in any version of Internet Explorer (including IE8).
css top attribute usage example
<html> <head> <style type="text/css"> img { position:absolute; top:5px; } </style> </head> <body> <img src="https://img.php.cn/upload/article/000/005/656/5af270fd37755429.jpg" / alt="How to use css top attribute" > <h1>This is a heading</h1> </body> </html>
Effect output:
The above is the detailed content of How to use css top attribute. For more information, please follow other related articles on the PHP Chinese website!