Home >Web Front-end >CSS Tutorial >What does margin-top mean?

What does margin-top mean?

不言
不言Original
2019-04-11 09:55:3234755browse

margin-top is a property in CSS, used to set the top margin of an element. All mainstream browsers support the margin-top property. Let’s take a brief look at the usage of the margin-top property.

What does margin-top mean?

The syntax of margin-top is as follows:

margin-top:value

The value of value has the following possibilities:

auto: The top margin set by the browser.

length: Define a fixed top margin. The default value is 0.

%: Defines the top margin as a percentage based on the total height of the parent object.

inherit: Specifies that the top margin should be inherited from the parent element.

Let’s take a look at a simple code example:

<html>
<head>
<style type="text/css">
p.topmargin {margin-top: 5cm}
</style>
</head>

<body>
<p>这个段落没有指定外边距。</p>
<p class="topmargin">这个段落带有指定的上外边距。</p>
</body>
</html>

The running results are as follows:

What does margin-top mean?

This article is all over here For more exciting content, you can pay attention to the CSS Video Tutorial column on the PHP Chinese website! ! !

The above is the detailed content of What does margin-top mean?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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