centering root div through percentage width in all kind of resolutions

后端 未结 2 895
傲寒
傲寒 2021-01-17 01:54

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

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

it will center

2条回答
  •  悲&欢浪女
    2021-01-17 02:25

    Here you go.

    WORKING DEMO

    The HTML Code:

     

    The CSS Code:

    #container
    {
      width:80%;
      margin:0px auto;
        background:green;
    }
    
    html{width:100%; min-width:100%;}
    

    Hope this helps.

提交回复
热议问题