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)