{position: relative; top:
-
50
%
; Width: 400px; margin:
0
Auto ;}
/*
For explorer only
*/
Div. greenborder {border: 1px solid green; Background
-
Color: ivory ;}
Style
>
Head
>
Body
>
Div ID
=
"
Outer
"
>
Div ID
=
"
Middle
"
>
Div
How do I use CSS to center the div display? For everyone to do a simple code, the use of CSS to achieve a div horizontal center display, the need for friends can learn from reference.
The main CSS code needed is two, one is text-align:center (content Center), the other is m
First, how to make a div vertically centered in the page (please list at least three kinds)1. The distance from the left and top border of the page window is set to 50%, this 50% refers to the width and height of the page window 50%, and finally the div to the left and move up, left and move up the size of the div is half the width and height.width:300px;height:2
For example, the. html file code is as follows,
Reference content is as follows:Center div
The method for implementing the center CSS Code is the first method:
Reference content is as follows:Body{Text-align: center;Background-color: # ccc;Min-width: 780px;}# MainDiv{Width: 760px;Border
The most common form of Div + CSS webpage layout is four modules: Top, center left, center right, and bottom. The width is PX, and the overall page is centered.
StructureCodeThe top left right foot modules are all independent and not nested.
The top part belongs to the general definition.
# Top {Height: 100px; Background: # CCC; width: 760px;
First scenario: The case of a DIV block inside the boxdiv.myid{display:flex;justify-content:center;align-items:center;height:500px;} Div.myid div.mydiv{width:200px;height:200px;border:1px solid Red;}Low-version browser compatibility is not good enough, choose to be cautious,The second option: to center the Div in the b
The perfect solution for DIV center is that when we refactor the WEB, we usually do the following for DIV center:
The Code is as follows:
Body {Margin: 0px auto;Text-align: center;}
However, when the following parsing method is
There are many ways to align Div horizontally. two common methods are introduced.
First, set left and right margin to Auto:
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->
Body {
Text-align: center;
}
. Center
Although the question of the middle and bottom of the div is already an older topic, it has recently been found that many front-end developers are asking how to implement it. In fact, there are already a lot of data and cases on the network, I will summarize some of the more common way of handling.
Case one: div limit high, content length limit LineThe code is as follows:
. v-
Today to bring you the code is a lot of friends need to use, CSS to achieve DIV center, the need for friends can collect this article, the need to use CSS to achieve the center of the div when you can easily use, with CSS to achieve the center of the
Although the question of the middle and bottom of the div is already an older topic, it has recently been found that many front-end developers are asking how to implement it. In fact, there are already a lot of data and cases on the network, I will summarize some of the more common way of handling.
Case one: div limit high, content length limit LineThe code is as follows:
. v-
[Bootstrap] How bootstrap2 directs div vertical center-CQ_LQJ URL: http://www.4byte.cn/question/138712/bootstrap-how-to-center-vertical.html
Some of them refer to the method on the webpage above. Those who have used bootstrap know that in bootsrap2, the grid layout can be used to center p horizontally. How can we
During web refactoring, The DIV center is usually like this:
CopyCode The Code is as follows: body {
Margin: 0px auto;
Text-align: center;
}
However, when the following parsing method is not stated, an error occurs on the page. The center cannot be aligned!Copy codeThe Cod
Css
Page Layout Technique example, want to let Div center, how to write CSS?
Div-Centered settings How do I write css? We are in the traditional table layout, as long as the table to set the center property to achieve the center of the block element. Application
CSS how to make div layer Horizontal center today with CSS encountered a very difficult problem, div itself does not define its own center of the property, many methods on the Web are introduced with the superior text-align:center and then nested a layer of div to solve the
When building a webpage layout, we often face a problem, that is, to align a div horizontally and vertically. Although there are several ways to achieve it, my favorite method is introduced today, implemented through css and jQuery.
1. Implement horizontal center through css:
The Code is as follows:
. ClassName {Margin: 0 auto;Width: 200px;Height: 200px;}
2.
How to center the entire page content, and how to automatically scale the highly adaptive content. This is the most common problem in CSS layout learning. The following is a practical example and detailed explanation. (The experience in this article is discussed by xpoint and guoshuang in the blue ideal forum .)
First, let's take a look at the actual running effect. This page can be adaptive to the center
In div + css, the width is not clear and the horizontal center is set to text-align: center and margin: 0 auto; but the horizontal center is still not allowed,
The overall width is unknown, there is a background, and the background can be extended.
Urgent! Urgent! Urgent!
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.