一个页面分为左中右3部分,中间部分像素固定为1000px, 中间部分要居中, 剩下左右2部分的宽度怎么设置
一个页面分为左中右3部分,中间部分像素固定为1000px, 中间部分要居中, 剩下左右2部分的宽度如何设置?
因为个显示器的分辨率不一致,需固定中间div的宽度,剩下2边的宽度如何设置?
<div style="background-color:red;height:200px;float:left"></div><div style="width:1050px;margin:0px auto;background-color:#aaa;height:200px;float:left"></div>
<div style="background-color:black;height:200px;float:left"></div>
------解决思路----------------------
注意 right: 50%; margin-right: -500px;这两个属性,这是要元素在浏览器中居中的,你要吧中间的div换成800,那么相应的 margin-right: -400px;。如果你要完全自适应就换成百分比,例如 width:80%; right: 50%; margin-right: -40%;
因为个显示器的分辨率不一致,需固定中间div的宽度,剩下2边的宽度如何设置?
<div style="background-color:red;height:200px;float:left"></div><div style="width:1050px;margin:0px auto;background-color:#aaa;height:200px;float:left"></div>
<div style="background-color:black;height:200px;float:left"></div>
------解决思路----------------------
注意 right: 50%; margin-right: -500px;这两个属性,这是要元素在浏览器中居中的,你要吧中间的div换成800,那么相应的 margin-right: -400px;。如果你要完全自适应就换成百分比,例如 width:80%; right: 50%; margin-right: -40%;