gpt4 book ai didi

jquery - 在各种分辨率下通过百分比宽度将根 div 居中

转载 作者:太空宇宙 更新时间:2023-11-04 13:54:35 24 4
gpt4 key购买 nike

我需要通过基于百分比而不是基于像素的宽度来使根 div 居中

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

它将使容器相对于页面居中,并在 1366 *706 分辨率下正常工作。 但不适用于 1280*1024

我需要将 div 居中以在两种分辨率下工作。使用百分比宽度概念时如何解决此问题。

谢谢,

湿婆

最佳答案

给你。

WORKING DEMO

HTML 代码:

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

CSS 代码:

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

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

希望这对您有所帮助。

关于jquery - 在各种分辨率下通过百分比宽度将根 div 居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21985587/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com