How to use css top attribute

藏色散人
Release: 2019-05-30 09:25:23
Original
5182 people have browsed it

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 css 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>
Copy after login

Effect output:

How to use css top attribute

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template