What does margin-top mean?

不言
Release: 2019-04-11 09:55:32
Original
34729 people have browsed it

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

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

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!

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