IE和HTML5文档类型问题 [英] IE and HTML5 doctype issues

查看:132
本文介绍了IE和HTML5文档类型问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用伟大的HTML5样板。这是一个伟大的项目,但我有一些在IE 8和7中渲染的大问题(可能是8,但还没有尝试过)。

这些文件具有HTML5文档类型:

 <!doctype html> 
< head>

但问题在于没有完整且丑陋的doctype,就像...

 <!DOCTYPE html PUBLIC -  // W3C // DTD XHTML 1.0 Transitional // ENhttp://www.w3.org/ TR / XHTML1 / DTD / XHTML1-transitional.dtd> 
< html xmlns =http://www.w3.org/1999/xhtml>

我得到所有类型的渲染问题:以margin为中心:auto不起作用,高度,宽度,mart和填充都表现得像疯了一样,所有我的布局被打破,只有<!doctype> 但如果我切换到旧的,一切都很好(不,很好,它仍然是IE浏览器,但正如预期的那样)



HTML5 Boilerplate带有Modernizer,我认为应该解决这个问题,但它不起作用。从我的研究(谷歌),我发现IE进入古怪模式宽度<!doctype> ,所以问题是......



有没有办法阻止IE进入怪癖模式,<!doctype>



或者至少不要打破边距,宽度,填充等?

编辑:是完整的头像:

 <!doctype html> 
<! - [if lt IE 7]> < html class =no-js lt-ie9 lt-ie8 lt-ie7lang =en>百分比抑制率ENDIF] - GT!;
<! - [if IE 7]> < html class =no-js lt-ie9 lt-ie8lang =en>百分比抑制率ENDIF] - GT!;
<! - [if IE 8]> < html class =no-js lt-ie9lang =en>百分比抑制率ENDIF] - GT!;
<! - [if gt IE 8]><! - > < html class =no-jslang =en> <! - <![ENDIF] - GT;
< head>
< meta charset =utf-8>


解决方案

IE不会与doctype一起进入怪异模式。样板文件应该修复IE问题,而不是导致它们。您缺少doctype之后的< html> 元素。加上这个来看看事情是否改变。 HTML5并不要求它,但如果缺少,根据文档,IE或样板文件可能会变得疯狂。

另外,只要删除doctype之后的注释,并且应该使问题就消失了。


I'm using the great HTML5 boilerplate. It's a great project but I'm having some big issues rendering in IE 8 and 7 (possibly 8 but haven't tried yet)

The files have the HTML5 doctype:

<!doctype html>
<head>

But the problem is that having no full and ugly doctype like...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

I get all kind of rendering issues: centering by margin:auto doesn't work, heights, widths, martings and paddings all behave like crazy and all my layout is broken with just <!doctype> but if I switch to the old one, everything works great (well, not great, it's still IE, but as expected)

HTML5 Boilerplate comes with Modernizer which I think should fix this but it's not working. From my "research" (Google) I found that IE enters in quirks mode width <!doctype>, so the question is...

Is there a way to prevent IE going into quirks mode with <!doctype>?

Or at least not to break margins, widths, paddings, etc?

Edit: This is the full head:

<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
  <meta charset="utf-8">

解决方案

IE does not go into quirks mode with that doctype. The boilerplate should be fixing IE problems, not causing them. You are missing the <html> element after the doctype. Add that to see if things change. HTML5 does not require it but, if missing, either IE or boilerplate may go crazy according to the docs.

Also, just remove the comments after the doctype and that should make the problem go away.

这篇关于IE和HTML5文档类型问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆