-
The width of the tree block is 50 (width) + 50 (left padding) + 50 (right padding) = 150px, and the added padding is the inner padding, and the background color is the same as the tree, so your blue block becomes 150px
If your blue block is only 50px, you have to use margin,, tree,, so that your blue block is only 50px wide, and the left and right margins are 50px
-
The CSS specification states that the border is drawn "above the background of the element". This is important because some borders are "discontinuated" (for example, dotted or dashed) and the background of the element should appear between the visible parts of the border.
CSS2 states that the background only extends to the padding, not the border. Later corrections were made: the background of the element is the background of the content, padding, and border areas. Most browsers follow the definition, although some older browsers may behave differently.
That is, the background includes the width of the content, the width of the padding-left and padding-right, and the width of the border, border-left and border-right, and your ** calculation result is 50 + 50 + 50 = 150
-
What is a blue block?
It should be tree! The width of this div becomes 150px and the height is 300px. The position occupied is the padding plus margin, width plus width, and border, which is equal to the total area occupied.
That is, the width of a box = padding + margin + width + border
-
Definitions and Usage.
The padding shorthand property sets all padding properties in one declaration.
Illustrate. This shorthand property sets the width of all the padding of the element, or the width of the padding on each side. The padding set on non-substitution elements in the line does not affect the line height calculation;
So, if an element has both padding and background, it may visually extend to other lines and may overlap with other content. The element's background extends through the padding. Specifying a negative margin value is not allowed.
If you just want the tree and surrounding elements to generate an example, use the outer edge
-
The actual total width of a box = width + border + padding, so you add padding: 50px and 50 pixels, 50 + 50 + 50 is of course 150px, but this situation does not exist in IE.
-
vue practice - CSS style position display float attribute comparison use.
-
You can try using margin. If the data is large, the padding will overflow, if you must use the padding you might as well calculate the size first.
-
First of all, try to use margin when you can use it (for example, when you don't need it);
If you must use padding, please try not to set a fixed value for width and height, which can be set as a percentage or as nothing, and take the default value (the default width of block-level elements is 100%, height is 0 or the actual height of the content), so that the overall size of the element will not change;
If you must specify a fixed value for width and height, you can subtract the padding value from this value, but it should be noted that the padding is divided into up, down, left, and right, so the width should subtract the sum of the left and right padding, and the height should subtract the sum of the upper and lower padding.
It's also important to note that the border of an element also occupies the actual width of the element, so if you want to keep the overall size of the element the same, you should also take the border into account, similar to padding.
The actual size of the elements is listed below, and you can understand the reason by studying it yourself
The actual width of the element = the width of the element + the left and right padding + the left and right borders
The actual height of the element = the height of the element + the upper and lower padding + the upper and lower border
Hello! Know how to get the value of wealth:
1.New users log in to Wealth +20 for the first time >>>More
1. The domain name must be consistent with the theme, so that the credit rating of your ** is applied. If it is possible in the early stage, it is best to use 301 to turn to sites with PR values greater than 4. >>>More
If you only choose from the N-series, I highly recommend you buy the N82! >>>More
From easy to difficult, it is divided into:
1. Lifting heavy objects. You can usually do more exercises to lift things, which seem to have nothing to do with wrist strength, but in fact, improving your grip strength is the basis for developing strong wrist strength in the future. >>>More
Difference Between Gasoline and 97 Gasoline: Gasoline has a different octane rating. The ability of gasoline to resist knocking is measured by octane number. >>>More