css007 Margin padding border
1, understand the box model (Box model: is to put something, including HTML various tags are included in a
In the Invisible Box)
1/Any label in a Web browser is a box that surrounds the different properties of the decorated box
Pad Ding: The distance between the content and its frame line
Margin: The distance between a label and another label
Border: Straight lines around the box
Background-color: Padding the space inside the border
2. Control the space with margin and padding (margin controls the space between the outer and other elements of the box;
padding controls the distance of the contents of the box from the box, and in general browsers there are default line spacing or various indentation distances. Generally use margin and padding to clear the zero. Margin and padding can be followed by 1 to 4 values, if it is two values, respectively, representing the upper and lower and the left and right. The General order is: upper right bottom left (the order must not mess up). Can specify a direction, such as Margin-top)
1. Margin and padding all add space around the content.
2. Margin conflict: When Margin-bottom encounters the margin-top of the following element (conflict), the browser is applied to the larger one between them (apply only one, not two add)
3, you can use the negative value of margin to eliminate unnecessary voids (margin is a relatively small number of negative values can be used as a CSS property.) Padding be sure to use positive values)
4, in-line box, block-level box and other display settings: CSS has two different boxes: Block box (blocks box) in-Line box (inline box)
5, display properties can change the box properties: Display:block/inline/inline-block;
3. Add border (border property. For example: border:1px solid #fff; The representative draws a 1 pixel,
The color is a black border. Border up and down and margin, padding usage of the same as in the practice of 1 of the bar PDF into HTML in many places with the use of border instead of <div> tags, which can eliminate some code overhead and time overhead. such as links to the green border of the overlay. Footer overlay for light green layers)
1, Border attribute block-level setting method: border:1px solid #fff;
2. Format each border individually: for example: border-top:1px solid red;
3. You can hide a border with none:
border:1px solid red;
Border-top:none; (two code represents a frame without a top)
4, you can also define the color, width, style for each border:(Can you set two bottom border for a box?) Is there a way to let the CSS style set in the back do not overwrite the previously set style?? )
such as: border-width:20px;
border-style:double;
border-color:red;
You can set a different color for the border:
BORDER:2PX Dashed
Border-color:red Yellow blue black;
4. Set the background color (background-color)
background-color:red;/#f00; /rgb (255,0,0);
5. Create rounded corners (the word forgot how to write it.) )
border-radius:20px (followed by the value if it is a position of four delegates (clockwise from the top left))
6. Add Shadow (Text-shadow, just learned in the previous section, for example:
text-shadow:5px 9px 2px #fff; where the first value represents the horizontal direction: Positive values are on the right. The second value represents the vertical direction, and positive values are below. The third value represents the degree of ambiguity, and the higher the value, the greater the blur, and the fourth value represents the color. (question: Can a third value be negative?) )
(The previous section is text, this section is a box)
Border-shadow followed by the same value as the Text-shadow usage in the previous section
There are two optional values: inset (embedded shadow) Spead (external Shadow)
Border:inset 3px 4px 5px red;
7. Determine the height and width (height and breadth are not inherited properties, but the following values can be filled in inherit to represent the width of the inherited parent class. The use of general border will be in line with the width of the high, so as to draw a normal shape out)
1. box-sizing Property Skip Frame width
Box-sizing:content-box;/padding-box;/border-box;
2. Control overflow text with overflow attribute
Overflow:visible;/scroll;/auto;/hidden;
3, the width of the minimization and maximization
Max-width
Max-height
Min-width
Min-width
8. Surround content with floating elements (float:left/right; Floats are more varied, after floating
Remember to clear the float, or it will affect the next HTML content, what problems will appear, horrible, the practice of 1 of the PDF into HTML, is not clear floating, a lot of problems tuned for a long time. Clear float: Can be written at the end of the float: Overfloat:hidden; can also be written in the following content: Clear:left/right/both;)
1, the background and the border is not floating ...
2, Clear:none; Turn off clear properties completely
Note: Blue for looking at the table of contents is based on the knowledge expressed before, black for reading after the addition or modification. Red is the problem that arises after the knowledge point has been read.
css007 Margin padding border