Div Center: The most complete div Center method Summary

Source: Internet
Author: User
In the Web page, I want to have the text or picture horizontally centered or vertically centered. The layout can be implemented conveniently using DIV+CSS. Well, I'll give it to him today. Using CSS to achieve div centering and using JS/JQ to center several methods:

CSS to implement Div centering method:

1. How do I use CSS to keep the div centered forever?

The example code in the above article is how to use CSS to keep the div in a permanently centered state, regardless of how the screen slides, the p is always in the center of the screen (support IE7 (including IE7), you will feel very simple when you read it, not surprisingly simple.


2. Using CSS to control the DIV center failure Solution

In general, the center of the div failure is because the DTD statement is not written, in fact, many other problems of CSS is also because no DTD statement caused, as long as the head with the content of the article, you can easily solve the problem!


3. CSS style to align P

The use of Margin-left:auto;margin-right:auto in this article; You can align your p in the center: Style{margin-left:auto;margin-right:auto; The abbreviated form is. style{margin:0 auto; The number 0 indicates that the top bottom margin is 0. Can be set to a different value as needed.


Js/jq How to implement DIV centering:

1.JS Implementation P-center example

P Center method has a lot, like the above we introduce the CSS Implementation Div Center, online can be found, but this article to introduce is to use JS to achieve, compare alternative, it is worth learning ~


2. Use JQ to get your p centered in a good way to share

Div Center can not only use CSS, JS implementation, JQ can also achieve Div center, this article is the use of JQ to achieve Div Center instance, after reading you will find code concise and clear, but also extrapolate.


Div Center related questions and answers:

1.CSS-How do I get the P centered in absolute positioning?

2.html5-html How to let P center ah??

3. Front-end-how to get img centered in P, IMG is longer than P


Div Centered Articles related recommendations:

1.CSS Image Center: CSS image centered around the top (horizontal and vertical center)

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.