如何让整个页面显示在浏览器中央
我在 contentplaceholder
母版页代码之外有三个 div:
<div id="content-outer" class="clear">
<div id="content-wrapper">
<div id="content">
<asp:ContentPlaceHolder ID = "ContentPlaceHolder1" runat="server" >
</asp:ContentPlaceHolder>
</div>
</div>
</div>
内容外部 div 的宽度为 1400px,它在宽度为 1400 或更大的屏幕中运行良好,但当我在宽度 1024 的屏幕中运行它时,整个页面从左侧开始, ,,我想在浏览器中打开时居中对齐我的页面,我给出了一些 css 属性,例如
content-outer: 左边距:自动; margin-right:auto;(不起作用)
但我无法居中对齐整个页面,,,请告诉我该怎么做,,我也为正文提供了相同的属性,但再次没有运气
i have three divs outside my contentplaceholder
masterpage code:
<div id="content-outer" class="clear">
<div id="content-wrapper">
<div id="content">
<asp:ContentPlaceHolder ID = "ContentPlaceHolder1" runat="server" >
</asp:ContentPlaceHolder>
</div>
</div>
</div>
the width of content outer div is 1400px,it works well in the screen whose width is 1400 or more but when i run it in the scree of width 1024, the whole page starts from left,,,i want to center align my page when open in the browser,i have given some css properties like
content-outer:
margin-left:auto;
margin-right:auto;(not working)
but i m not able to center align my whole page,,,plz tell me how can i do that,,i have also given the same properties for body but again no luck
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,中心标签的使用已被弃用,因此您不应该使用它。
您的解决方案(为了清楚起见,我将 css 内联)
是在页面上居中内容的正确方法。
正如您所注意到的,如果屏幕小于内容宽度,它看起来不会居中。这是因为页面左侧或右侧没有足够的边距空间,并且在页面中间启动浏览器滚动条会不一致。
您的选择是:
希望这有帮助。
Firstly, the use of the center tag has been deprecated, so you shouldn't use it.
Your solution of (I've put the css inline for clarity)
Is the correct method of centering content on a page.
As you have noticed, if the screen is smaller than your content width, it doesn't appear to be centered. This is because there is no space for a margin on the left or right of the page and it would be inconsistent to start the browser scrollbar in the middle of the page.
Your options are:
Hope this helps.
只是玩以下风格
just playaround with following styles