html居中问题_html/css_WEB-ITnose

原创
2016-06-24 12:10:30757浏览

做页面时,是在body里加个层

,然后使#wraps{ margin:0px auto; width:960px;}

这样居中是居中了,但是,当内容改变使body出现垂直滚动条时,就会发生内容整体水平移动动的情况,

目前我想到的解决方法是让垂直滚动条始终显示,但是不知道该怎么做?或者各位有什么其他好的解决办法?

注:页面高度是不确定的,所以垂直滚动条的有无也是不确定的。



回复讨论(解决方案)

body,html{width:100%;height:100%;overflow-x:hidden;min-width:960px;margin:0;padding:0;}

body,html{width:100%;height:100%;overflow-x:hidden;min-width:960px;margin:0;padding:0;}

行不通啊

滚动条大概会产生10几个像素的距离,margin 左右 auto 当然会重新计算,会有稍微的调整。难道你想不让它重新计算?

最好不要 width:960px; 给百分比 能控制 滚动条

								
123


这个意思?

5楼的,如果切换浏览器窗口大小呢?最大化,还原……

HTML code








"); }; //check document ready function docReady(t) { "complete" === document.readyState || "interactive" === document.readyState ? setTimeout(t, 1) : document.addEventListener("DOMContentLoaded", t); } //check if wwads' fire function was blocked after document is ready with 3s timeout (waiting the ad loading) docReady(function () { setTimeout(function () { if( window._AdBlockInit === undefined ){ ABDetected(); } }, 3000); });