Home > Web Front-end > Front-end Q&A > What do inline properties mean?

What do inline properties mean?

藏色散人
Release: 2020-07-02 10:43:30
Original
3424 people have browsed it

The inline attribute refers to the inline style attribute, and the style attribute specifies the inline style of the element, and because the inline element also has a box model, different css attributes can be set for the inline element, such as width, height, Padding and margins, etc.

What do inline properties mean?

The style attribute specifies the inline style of the element

Inline element attribute settings

Inline elements also have a box model

Inline elements also have a box model, so you can set different css attributes for the inline elements, such as width, height, padding and Margins, so do inline elements need to set these attributes?

Setting the width and height of inline elements

It is invalid to set the width and height of inline elements

.span1 {
    height: 200px;
    width: 200px;
}
 
<span class=&#39;span1&#39;>行内元素设置宽度和高度</span>
Copy after login

At this time, we observe the page and box From the rendered model, you can find:

Even if the width and height are set for the inline element, the specific width and height displayed by the inline element are the width and height of the content itself, so set the width and height for the inline element. High is invalid

Inline element setting padding and margin

will affect the left and right, but not the top and bottom

Inline element setting padding and margin upper and lower specific value performance

<span class=&#39;span2&#39;>行内元素设置边距上下属性</span><br>
 
.span2 {
    padding-top: 20px;
    padding-bottom: 30px;
    margin-top: 40px;
    margin-bottom: 50px;
}
Copy after login

From the above picture, we can find that we have set the padding-top, padding-bottom, margin-top, and margin-bottom attributes for the inline elements, but these attributes have no specific effect. The effect seems to be It was stretched open, but it did not affect other elements.

Inline elements set padding and margin left and right specific value performance

The effect will occur

<span class=&#39;span3&#39;>行内元素设置边距左右属性</span><br>
 
.span3 {
    padding-left: 100px;
    padding-right: 200px;
    margin-left: 300px;
    margin-right: 400px;
}
Copy after login

As can be seen from the above figure, if we set padding-left, padding for inline elements The -right, margin-left, margin-right attributes will affect the position of the elements in the line

For more related knowledge, please visit PHP Chinese website!

The above is the detailed content of What do inline properties 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