在所有类型的分辨率中通过百分比宽度定中心根div [英] centering root div through percentage width in all kind of resolutions

查看:121
本文介绍了在所有类型的分辨率中通过百分比宽度定中心根div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要通过基于百分比的宽度而不是基于像素来定位根div。

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

它将使容器分别以页面为中心,并在1366 * 706 reoslution 。 但不适用于1280 * 1024



我需要将div置于两种类型的分辨率中。如何在使用百分比宽度概念时解决此问题。



谢谢,



Siva

$



/jsfiddle.net/xy6dF/rel =nofollow>工作演示



HTML代码

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

CSS代码

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

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

希望这有帮助。


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

解决方案

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.

这篇关于在所有类型的分辨率中通过百分比宽度定中心根div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆