问题描述
您好。
对不起,如果以前已经回答过这个问题。我使用一个主包装div来
将整个网站放入其中。我使用
margin:0 auto 0 auto
以使页面居中。但在IE中失败了。是否有解决方法
这个?
谢谢
您可能没有使用完整的doctype声明(这使得
IE渲染在quirksmode中),或者您使用的是IE5。 />
解决方案一:使用以下文档类型启动页面:
<!DOCTYPE HTML PUBLIC" - // W3C // DTD HTML 4.01 // EN" ;
" http://www.w3.org/TR/html4/strict.dtd">
(在IE5 btw中没有帮助)
解决方案二:
-
Els
可访问的网页设计:
您可能没有使用完整的doctype声明(这使得
IE渲染为quirksmode),或者您使用的是IE5。 />
解决方案一:使用以下文档类型启动页面:
<!DOCTYPE HTML PUBLIC" - // W3C // DTD HTML 4.01 // EN" ;
" http://www.w3.org/TR/html4/strict.dtd">
(在IE5 btw中没有帮助)
解决方案二:
一致的网络浏览器统计相关网站认为MSIE 5.x
现在代表世界浏览器使用统计数据的1%。
等
我认为现在是时候停止思考如何有效标记
代码和有效的CSS代码(触发符合标准的渲染模式
在浏览器中支持doctype切换)将在
越野车,不兼容的浏览器(如MSIE 5.x)中呈现,并告诉网络作者
使用严格的DTD并使用有效的标记代码和有效的CSS代码或
告诉用户升级或切换到更好的浏览器(Firefox 2或
Opera 9或Safari 2)。
在网页中使用Web标准
第2.2.3.2节我使用< centeror align =" center"。如何与CSS对齐?
CSS1 text-align属性指定文本或内联元素的方式(如
图像)在元素中对齐。
CSS" margin-left:auto; margin-right:auto;"属性将在其包含块中居中
块级元素。定义margin-left
和margin-right适用于块级元素。当margin-left和
margin-right都是auto时,它们被设置为相等的值,从而将
块级元素置于其父级中。
参考文献:
CSS1水平格式化
值得一提的是优秀的教程:
使用D. Dorward中心使用CSS
还有关于CSS水平对齐和水平格式化的交互式演示
G ?? rard
-
在网页中使用Web标准(2006年12月更新) )
我完全同意 - 但我已经看到人们在过去的4年里在Usenet上为这个
说了这些(他们可能在做在那之前,但我当时并没有在互联网上获得
),而且它似乎仍然不会沉沦于
''some''人。关于如何通过
来获取此人的任何建议? :-)
BTW,我还有客户告诉我页面上出了什么问题
IE5中的
(虽然主要是MacIE5,但是我有权访问的任何统计数据超过0.1%
- 我必须假设这是因为他们有
访问它:-(
-
Els
无障碍网页设计:
Hello.
sorry if this has been answered previously. I use a main wrapper div to
put the whole site in it. And I use
margin: 0 auto 0 auto
in order to center the page. But in IE it fails. Is there a workaround
for this?
Thanks
You are probably not using a complete doctype declaration (which makes
IE render in quirksmode), or you are using IE5.
Solution one: start your page with a doctype such as:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
(which won''t help in IE5 btw)
Solution two: http://locusmeus.com/html-css/centeringpage.html
--
Els http://locusmeus.com/
accessible web design: http://locusoptimus.com/
You are probably not using a complete doctype declaration (which makes
IE render in quirksmode), or you are using IE5.
Solution one: start your page with a doctype such as:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
(which won''t help in IE5 btw)
Solution two: http://locusmeus.com/html-css/centeringpage.html
A unanimity of web browser stats related sites consider that MSIE 5.x
represent now about 1% of world browser usage stats.
http://www.thecounter.com/stats/2007/March/browser.php
http://marketshare.hitslink.com/report.aspx?qprid=6
etc.
I believe it is very much time to stop thinking about how valid markup
code and valid CSS code (triggering standards compliant rendering mode
in browsers supporting doctype switching) are going to be rendered in
buggy, non-compliant browsers like MSIE 5.x and to tell web authors to
use a strict DTD and to use valid markup code and valid CSS code or to
tell users to upgrade or to switch to a better browser (Firefox 2 or
Opera 9 or Safari 2).
Using Web Standards in your Web Pages
Section 2.2.3.2 I use <centeror align="center". How to align with CSS?
http://developer.mozilla.org/en/docs...your_Web_Pages
The CSS1 text-align property specifies how text or inline elements (like
an image) are aligned within an element.
CSS "margin-left: auto; margin-right: auto;" properties will center a
block-level element within its containing block. Defining margin-left
and margin-right is for block-level elements. When both margin-left and
margin-right are auto, they are set to equal values, thus centering a
block-level element within its parent.
References:
CSS1 horizontal formating
http://www.w3.org/TR/REC-CSS1#horizontal-formatting
Worth mentioning is the excellent tutorial:
Centring using CSS by D. Dorward
http://dorward.me.uk/www/centre/
Also Interactive demo on CSS horizontal alignment and horizontal formating
http://www.gtalbot.org/NvuSection/Nv...Alignment.html
G??rard
--
Using Web Standards in your Web Pages (Updated Dec. 2006)
http://developer.mozilla.org/en/docs...your_Web_Pages
I agree completely - but I''ve seen people say this on Usenet for the
past 4 years now (they probably were doing it before that but I wasn''t
on the Internet yet then), and it still doesn''t seem to sink in with
''some'' people. Any suggestions on how to get through to people on
this? :-)
BTW, I also still have clients who tell me what goes wrong on a page
in IE5 (although mostly MacIE5 admittedly, which has less than 0.1% in
any stats I have access to) - I must assume this is because they have
access to it :-(
--
Els http://locusmeus.com/
accessible web design: http://locusoptimus.com/
这篇关于IE中的自动边距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!