How does margin work? Summarize margin Instance usage

Source: Internet
Author: User
The question of how CSS vertically centers an element is already a cliché. Whether for a novice or a veteran, during the interview is often asked. Two days ago in a flex video tutorial, which mentions the question of the center of the element, so today small series to grilled a few common ways. Shortcomings please criticize (all the code is self-tapping available) 1, the horizontal center (margin:0 auto;) about this, we should be the most unfamiliar, whether in the training course or self-study. This should be the first way the teacher speaks (horizontally), but there is a premise that the element being wrapped cannot have a floating property. Otherwise, the attribute will be invalidated. Specific as code:<style> body{margin:0;}

1. Summary of the front-end performance Note points

Summary: The question of how CSS vertically centers an element is already a cliché. Whether for a novice or a veteran, during the interview is often asked. Two days ago in a flex video tutorial, which mentions the question of the center of the element, so today small series to grilled a few common ways. Shortcomings please criticize (all the code is self-tapping available) 1, the horizontal center (margin:0 auto;) about this, we should be the most unfamiliar, whether in the training course or self-study. This should ...

2.10 articles on the SSM framework recommendation

Summary: The CSS margin property defines the space around the element. Marginmargin clears the area around the element (outer border). Margin without background color, is completely transparent margin can be changed individually on the top, bottom, left and right margin of the element. You can also change all properties at once. &nbsp; Margin can use negative values, overlapping content. &lt;h2margin-=&quot;&quot; Unilateral margin property in CSS, it can specify different sides of the margin: instance marg ...

3. Recommended 10 CSS Page layout effects (Favorites)

Summary: Why calculate the width of the Web page pixel width is for the CSS page layout neat and compatible. The common layout of the left and right structure of the page or use padding, margin layout will calculate the full width of the page, if not calculated whether the width is too high or small will appear dislocation problem. How to calculate CSS Width Example one: We calculate the layout style of a left and right structure. If the total width is 400px, then the left and right add up should be less than 400px, then we may be 300px on the left, right 100px correct code: &nbsp;&lt;! DOCTYPE ...

4. Recommended 10 articles on knowledge summary

Introduction: Friends In the initial study of CSS, the first time to learn the basics of CSS must have learned padding,border and margin, that is, the inner margin, border, margin. They make up the simplest boxes. The standard box model is typically used to add the DOCTYPE statement to the top of the page. With the DOCTYPE statement, all browsers will use the standard box model to explain your box, and the Web page will appear consistent across browsers. The compatibility with the browser is very friendly. Here I am ...

5. PHP implementation of Shopping Cart Instance code summary

Introduction: First, there are a few simple login pages &lt;body&gt;&lt;form&nbsp;action=&quot;chuli.php&quot;&nbsp;method= &quot;post&quot;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&lt;p&nbsp;style=&quot; Margin-left:&nbsp;500px;&nbs

6.10 article recommendations on block elements

Summary: When you do not include the Z-index property and the Position property, the stacking order of all elements coincides with the order in which they appear in the HTML document in which they reside. (except for exceptions that use negative margin to overlap an inline element.) When the element floats float, the floating block element is placed between the non-anchored block element and the anchor block element, in other words, the floating element appears above the descendant block element in the normal stream, below the descendant inline element in the normal stream. When an element is added to the position Location property, all elements with the position attribute and their child elements are displayed in their ...

7. About PHP Is_uploaded_file () functions 10 articles recommended

Introduction: index.php Copy code code as follows: ICO icon online conversion body{background-color: #fff; color: #000000; font-family:arial;margin:30px;font-size : 12px;} table{border:0} td{line-height:16px;} Label{cursor:hand;} ico icon online conversion, ....

8. Recommended course for boundary overlay

Introduction: This paper mainly introduces the problem and solution of margin boundary overlay in CSS. Has a good reference value. Let's see it together. css margin Overlay depth anatomy boundary Overlay Introduction Boundary overlay is a fairly simple concept. However, when you lay out a Web page in practice, it creates a lot of confusion. Simply put, when two vertical boundaries meet, they form a boundary. The height of this boundary is equal to the larger of the two height of the bounding boundary where the overlay occurs. When an element appears on top of another element, the bottom boundary of the first element is the second element ...

9. Summary of how to use copy buttons in HTML

Introduction: margin:0px; padding:10px 0px 5px; font-size:14px; Color:rgb (37, 37, 37); Font-family:arial, &quot;microsoft Yahei&quot, song body, Sans-serif; White-space:normal; Background-color:rgb (255, 255, 255);..

10. A detailed introduction to sibling

Summary: How the sibling selector keeps CSS readable while completing complex design requirements This is one of the more complex examples of the beginning of a simple, gradual change in the Web front-end development process: Applying the vertical margin (vertical margins) to all elements in an article For example, a blog post compiled by a complex markdown. In most cases, you have to deal with many exceptions and correlations, such as: headings and images often require more whitespace, but if the two images are next to each other, the gap between the two graphs will change less. H2 label and H3 tag are directly closer than two ...

"Related question and answer recommendation":

CSS-H5 Mobile Page The effect of Margin-top/padding-top/height value on different phones is different how to solve

Why CSS set margin:0 auto; Invalid horizontal center?

Android-iconmarginspan text does not wrap the problem, with Dynamicdrawablespan and Imagespan icon no margin

Why is there a gap between the top and bottom of each block?

JavaScript-Reorganize the Li list based on known conditions

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.