How to make my page load centered using CSS, HTML or really basic javascript
Hello Ive made a page which has an image of width 1300px as its widest point. I'm trying to make something which makes the page load with the centre of the page (where text etc. resides) in the middle of the browser. I开发者_Python百科s there a simple way of doing this?
Add this to the outer wrapper CSS:
width: <text width>px;
margin: 0px auto;
And make the image a centered background of the body:
background: url(image.png) top center;
in CSS, do this:
body: { text-align: center } #main { text-align: left margin: 0 auto; }
The text-align center is for old IE6, whereas margin works for newer browsers. #main is your main div that is to be centered.
if you want to display some block elements (with fixed width) centered you need to use this rule:
margin:0 auto;
if inside an element you want to center some text, just set:
text-align:center;
if you want to center an absolute element (fixed widh aswell, i.e. 1300px) you need to be more tricky this way:
margin-left:-650px;
left:50%;
Body{margin: 0px;}
.wrapperDiv{Margin: 0 auto;}
精彩评论