Source: http://www.ido321.com/387.htmlIf you think this should be the case:That's a mistake. The result is this:Because there is a margin collapse in the CSS, the boundary collapses or the boundaries overlap. For the top and bottom two paralleldiv block, the margin-bottom of the upper Div and the
I. The principle of negative marginThe positive margin is moved by the position of the adjacent module, and the surrounding modules are appropriately excluded.A negative margin, or margin, is a negative four boundary value.Using negative margins Margin-left and margin-top in
For the following simple code:If you think this should be the case:That's a mistake. The result is this:Because there is a margin collapse in the CSS, the boundary collapses or the boundaries overlap. For the top and bottom two parallel div blocks, the above Div's margin-bottom and the following Div's
I have always thought that the margin property is a very simple property, but recently I have encountered some problems in the project, only to find that the margin property has some "pits", I will introduce the basic knowledge of margin and the "pit". This blog post is mainly divided into the following sections:
marg
The margin property can determine the wide height of many HTML elements, so it can also play an important role in layout, so let's take a look at the use of the margin property of CSS in the page layout. Introduction
Basis
1. Element containing-box width height equals content width
Html
Css
. wrap { float:left;
4 margin overlapping calculation rules .A) positive fetching large valueB) Addition of positive and negative valuesC) Negative negative take the most negative.5. Meaning of margin overlapA) Consecutive paragraphs or lists, if there is no margin overlap, 1:2 will appear uncoordinated.B) nesting or directly placing a div
css| optimization
Margin is one of the most commonly used properties in CSS layouts, but if not properly used, it tends to produce too much junk code, allowing our coding volume to grow. Today we introduce a small example of coding optimization, through this example, we hope that you can realize that the path of code optimization is a variety of, but also a prime
1. Some special font styles:Indent 2 characters in first line: {text-indent:2em;}Center horizontally: {text-align:center;}Justify: {text-align:justify;}Center vertically: {vertical-align:middle;}Word spacing 2 characters: {letter-spacing:2em;}Line spacing twice times: {line-height:2;}2. The navigation bar is fixed somewhere on the page (relative to {position:fixed;left:px;top:px;}3. Block-level elements and inline elements: Common block-level elements:Common inline elements:, Block-level elemen
Source: http://www.ido321.com/387.htmlSuppose you think it should be this:That's a mistake.The result is this:Because there is a margin collapse in CSS, the boundary collapses or the boundary overlaps. For the top and bottom two paralleldiv block. The margin-bottom of the above div and the
, and margins are no exception. For example, in a browser that supports CSS, margins generate a "blank line" above and below each paragraph element. Therefore, if the margin is not declared for the P element, the browser may apply an outer margin on its own. Of course, the default style will be overridden as long as you specifically make a declaration.
Value repl
In CSS, width and height refer to the widths and heights of the inner regions. Increasing the padding, borders, and margins does not affect the size of the content area, but increases the total size of the element box. (The actual footprint of the div has changed.)But:Once the appropriate DTD has been set for the page, most browsers will render the content as shown above. However, the rendering of IE 5 and
first, solidify the box model . :Visible dimensions within the solid line (clientwidth and clientheight);Within a dashed line of margin is the Occupy Size.Several special effects of margin:1, Change the client size: a set of Fixed-width adaptive layout:egFor this page, let IMG float on the left, and the text inside will wrap around the image:Blue is the P tag content block size, and yellow is the default
Css-inline (in-row) elements, block elements, margin, and padding
Features of block elements:
Always starts on a new line;Height, row height, and top and bottom margins can be controlled;The default width is 100% of its container unless a width is set.
Features of the inline element: And other elements are on one line;High, the Row Height and top and bottom margins cannot be changed;The width of a text or
Why does css sub-element margin-top affect the parent element? cssmargin-top
For details, click
This problem has been confusing for a long time. Although there is no major problem, I have come to know how to solve it, but I still don't know what the cause is. If there is a problem with IE, I don't care too much, but the problem is that all the top-level browsers are doing this. How can I feel at ease? Tod
;
Top margin and bottom margin are 10px
Right margin and left margin are 5px
Example 4margin:10px;
All 4 margins are 10px
value Description The Auto browser calculates the margin. Length Specifies the value of the
You are learning margin and padding when you are ignorant,--what his Niang inner margin, what his niang margin. Oh ah, at first I also a bit do not understand, and later through the study of information learning finally figured out, and now I will talk about their own margin and padding understanding:
First, what is t
consistent distance between elements
Only the vertical boundary of a block box in a normal document stream occurs with a boundary overlay. The bounds between the inline, floating, or absolute positioning boxes do not overlap.
the problem of boundary superposition
Side-Office stacking is a CSS feature that can cause a lot of trouble if misunderstood. Refer to a simple example of a nested paragraph in a D
columns are implementedOn the same horizontal line. And the width is adaptive, and do not worry about a series of problems floating.Style section:
. fixed-height{height:200px;width:200px;Background: #666;}. flow-height{margin-top:-200px;margin-left:200px;}
Page structure:
High-fixed,Height-width adaptive, la la la ... Height-width adaptive, la la la ...
2. In the processing of border lines such as ta
Problem and Countermeasure: CSS margin collapse (collapse)-jerrylsxu
2:
3:
4:
5:
6:
27:
28:
29:
30:
31:
32: Span2
33:
34:
35:
36:
37:
If you think it should be like this:
That's wrong. The result is as follows:
Because there is a margin collapse in CSS
I believe many of my friends will encounter this problem when making div + css pages, because the explanation of HTML tags and CSS style sheets in IE series browsers is different from that in other browsers, therefore, some small bugs and webpage misplacement often occur during page creation. The following Webmaster will explain how to be compatible with various
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.