How to make div in html centered on the page
Recent bored again review the next html, I found a lot of things are forgotten. I tried to write a html page, and even how the results div centered on the page are checked a long time to get it out. In fact, I do not know why this can be achieved because the css has not carefully studied, so I attended the re-examination will certainly look very carefully explored. Since realized, I tried to get recorded, or else the next time forgot. Code is as follows (this is the outermost layer of a web page's css div style):
#all{
width: 800px;
height: 450px;
border: 1px solid green;
position:absolute;
top:50%;
left:50%;
margin:-225px 0 0 -400px;
}
In general, that is, absolute positioning, set the width and height, top and left set to 50%, margin is set: on half the height, the width of the left half.
Achieve the results shown in Figure:
web page green line that is the outermost div.
One year later, only write so a blog today, I look forward to the next study and write. ?