Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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>

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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top