tags:

views:

48

answers:

3

Hello, how can i set div position at the center of the page with size, for example, 80%/80%.

UPD: margin: 0 auto; works, but only for horizontal alignment. And i also need vertical.

+1  A: 

Set a fixed width and auto-margins.

<style type="text/css">
#center {
  width:300px;
  margin-left:auto;
  margin-right:auto;
}
</style>

<body>
<div id="center"></div>
</body>
timdev
I know this. I wanna do that not only for sides... But for top and bottom.
Ockonal
A: 

This does what you want, but it is not pretty.

<div style="margin: 0 auto;width:80%;height:80%;">
This will probably not work for you however because you did not provide code
</div>
Khufu
+2  A: 

This page talks about some different ways to achieve vertical centering using css. I've used method 2 before with success but I consider all of these a hack at best.

smack0007