One, "margin: Margin"
1. Write only a value indicating that the margin around is a specified value
2. Write two values, the first number is the top and bottom margin, the second value is left and right margin
3. Write three values, representing the top, right, and bottom three directions, left default equals right
4. Write four values, indicating top, right, bottom, left
The top, right, bottom, and left margins are also set by using the following four separate properties:
Margin-top
Margin-right
Margin-bottom
Margin-left
5.margin:0 Auto; Set block-level elements to be centered horizontally in the parent container
Second, "padding: Internal margin"
Set in exactly the same way as margin
The top, right, bottom, and left margins are also set by using the following four separate properties:
Padding-top
Padding-right
Padding-bottom
Padding-left
Note: Setting the padding will cause the div to brace up, using the need to pay attention to the actual height of the div;
"Give me a chestnut."
#box { width:70px; margin:10px; padding:5px;}
Three, "box model Classification"
1. Standard box model (box): We set the width height to include only the content section.
Add padding or border again. Will cause the box to become larger;
2, IE box model (weird box): We set the width and height, including content+padding+border;
adding padding or border will compress the content area, but the total size of the box does not change;
[Manually set box type]
Box-sizing:border-box; Weird box;
Box-sizing:content-box; Standard box; default effect.
Four, "border"
1. Set border requires three properties, width, style, color
2. In principle three attributes are indispensable, the order can be arbitrarily modified;
3. You can use Top,right,bottom,left to set four sides respectively
. border:5px Soild Blue;
4. Defining a single-sided style
To set the border style for one edge of an element box instead of setting the border style for all 4 edges, you can use the following single-sided border style properties:
Border-top-style
Border-right-style
Border-bottom-style
Border-left-style
"Give me a chestnut."
.div-1{
width:200px;
height:200px;
Overflow:hidden;
border:5px solid red;
}
.div-2{
width:100px;
height:100px;
position:relative;
left:50%;
margin-left: -55px;
top:50%;
margin-top: -50px;
border:5px dotted green;
}
When the parent box wraps the box and adds a margin-top to it, the sub-box cannot be separated from the parent box's top line, but instead causes the two boxes to come down simultaneously.
"Solution"
1. Add a little padding-top to the parent box, and it will cause the parent box structure to be extra 1px padding if not recommended.
2, add 1px border-top to the parent box, also lead to 1px of extra space, is not recommended to use.
3. Add Float to Parent box or child box;
4. Add the overflow property to the parent box and the recommended method.
V. "Border-radius fillet"
1.border-radius: You can accept 8 attribute values:
X-axis: Upper-left upper-right lower-left/y axis: Upper-left top-right lower-left bottom
2. Abbreviated form:
Only the X-axis is written, and the y-axis defaults to the x-axis;
Four corner is not complete, the default diagonal is equal;
Write only one value, default 8 numbers equal;
For example: border-radius:50px 20px;
=border-radius:50px 20px 50px 20px;
=border-radius:50px 20px 50px 20px/50px 20px 50px 20px;
3. When the rounded arc >= half of the square side, it will be displayed as a circle.
"For instance."
. div-1{
width:200px;
height:200px;
Background-color:yellow;
border-radius:50px 20px 50px 20px;
}
. div-1{
width:150px;
height:150px;
border-radius:50%;
Overflow:hidden;
}
. div-2{
width:100px;
height:100px;
border-radius:50%;
margin:25px Auto;
}
vi. "border-image: Picture Border"
1.border-image: A total of 10 attribute values can be placed:
A. Picture path: url ();
B. The slice width of the picture: 4 values, respectively: top, right, bottom, left four sides;
with four tangent cuts, you can divide the picture into 9 palaces. 9 Palace grid Four Corners corresponding to the four corners of the border (no stretching), 9
four sides corresponding to four border (will be stretched/finished/repeated according to the settings)
Note: When writing, you must not bring PX units.
c. Width of the border: 4 values, representing the width of the top, right, bottom, and left four borders;
Note: When writing, the PX unit must be used with/separated from the width of the slice.
d. How to repeat the border: strtch (stretched), round (paved), repeat (repeat)
"For instance."
. image{
width:200px;
height:200px;
background-size:200px 200px;
Background-color:darkslategray;
Border-image:url (images/ima.png) 27/27px stretch;
-webkit-border-image:url (images/ima.png) 27/27px repeat;
}
Vii. "Round and repeat differences"
1.round will compress the four edges appropriately to ensure that four edges can repeat integers.
the repeat will keep the length width of each edge unchanged, possibly leading to a full edge at Four Corners.
2. The notation of the attribute value: Border-image:a b/cpx D;
3.border-image: In the WebKit kernel browser, the-webkit prefix must be prefixed. */
eight, "Box-shadow: Box Shadow"
1.6 attribute values, separated by spaces:
X-axis shadow distance (required): Can be negative, right shift, negative one left shift;
Y-axis shadow distance (required): can be negative, positive move, negative one up;
shadow Blur radius (optional): only positive, default 0, the greater the value, the more blurred the shadow;
Shadow expansion radius (optional): Can be negative, default 0, value increases, shadow increases, and vice versa.
shadow Color (optional): default black;
internal and external shadows (optional): Default outer Shadow, inset represents inner shadow.
"For instance."
. shadow{
width:200px;
height:200px;
Background-color:darkslategray;
box-shadow:10px 10px 10px 5px black;
}
Nine, "Outline: Peripheral Line"
Appears outside the border and does not occupy space. May overwrite the surrounding content.
For example: outline:20px solid red;
"For instance."
. div-1{
width:200px;
height:200px;
Background-color:yellow;
outline:10px solid red;
}
CSS Box model