Center content on page using CSS

I am trying to create a lead generation page. I want to concentrate all the content on the page to the center when displayed in any browser size.

I tried to use the center of vertical alignment. But that doesn't seem to work.

What are the best methods for doing this?

http://play.mink7.com/h/mspre/

+5
source share
3 answers

If you mean only centering between the left and right edges, you create an element with a fixed width and declare margin: auto;on it.

If you want to center the element both horizontally and vertically, you position it halfway horizontally and vertically, then pull it half the width and height of the element.

:

.someElement {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 200px;
  height: 200px;
  margin: -100px 0 0 -100px;
}
+8

- div . 900 , , , . div .

#container { width: 900px; 
margin: 0px auto 0px auto; 
}

div. .
, .

Mike

+2

All Articles