Home > Article > Web Front-end > What do inline properties mean?
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.
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='span1'>行内元素设置宽度和高度</span>
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='span2'>行内元素设置边距上下属性</span><br> .span2 { padding-top: 20px; padding-bottom: 30px; margin-top: 40px; margin-bottom: 50px; }
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='span3'>行内元素设置边距左右属性</span><br> .span3 { padding-left: 100px; padding-right: 200px; margin-left: 300px; margin-right: 400px; }
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!