SivaRajini
SivaRajini

Reputation: 7375

centering root div through percentage width in all kind of resolutions

i need to center the root div through percentage based width not pixel based

#container
{
  width:80%;
  margin:0px auto;
}

it will center the container respective to page and working fine in 1366 *706 reoslution. but not working in 1280*1024

i need to center the div to work in both kind of resolutions. how can i resolve this issue when using percentage width concept.

Thanks,

Siva

Upvotes: 0

Views: 160

Answers (2)

Nitesh
Nitesh

Reputation: 15779

Here you go.

WORKING DEMO

The HTML Code:

<div id="container">&nbsp;</div>

The CSS Code:

#container
{
  width:80%;
  margin:0px auto;
    background:green;
}

html{width:100%; min-width:100%;}

Hope this helps.

Upvotes: 1

Neharika
Neharika

Reputation: 95

add padding-left and padding-right. also give width=100%

Upvotes: 0

Related Questions