Inline elements can be understood to not directly set width and height elements, such as span, and you have no effect on the width and height you set for him unless you set it to block-level elements.
The width and height will not work if the following code removes the Display:block property value.
1 |
< span style = "width:100px;height:100px;display:block;" ></ span > |
Margin controls the spacing between inline and block-level elements, not just inline elements.
It is important to note the conversion issues between them, such as block-level elements plus the float property becoming inline elements.
--------------------------------------------------------------------------------------------------------------- -----
The maximum property values used by display are: Blocks (block-level elements), inline (inline elements), inline-block (inline block elements)
It's easy to say:
Block-level elements (blocks): can be set wide height, margin,padding value, etc.;
12 |
< div >我是块级元素DIV!</ div > < p >我是块级元素P!</ p > |
The result of the above display:
inline element (inline): Can not set width height, margin,padding value, etc.;
12 |
< span >我是内联元素SPAN!</ span > < em >我是内联元素EM!</ em > |
The results shown above (will appear in a row, when you set the width high, the margin,padding value does not work):
Inline block Element (Inline-block): You can set the width height, margin,padding value
12 |
< span >我是内联元素SPAN!</ span > < em >我是内联元素EM!</ em > |
Css:
1 |
span,em { padding : 0 5px ; display : inline- block ;} |
The effect shown above will be in a row, but at the same time the width is high, the margin,padding value also works;
CSS Inline with block