简体   繁体   English

HTML5和CSS3:如何确保我的代码与所有浏览器兼容?

[英]HTML5 & CSS3: How can I make sure that my code is compatible to all browsers?

Whenever I am working with webdesign every browsers shows something different which ruins the layout. 每当我使用网页设计时,每个浏览器都会显示不同的东西,这会破坏布局。 Is there any tools or guidelines to make a webdesign without any problems? 是否有任何工具或指南可以毫无问题地进行网页设计?

Thanks in advance! 提前致谢!

There are a lot of different tools and technologies that can help make this better/easier but nothing beats good old cross-browser testing. 有许多不同的工具和技术可以帮助使这更好/更容易,但没有什么比旧的跨浏览器测试更好。 Here are some tools you might like: 以下是您可能喜欢的一些工具:

I don't think that all designs must look the same in all browsers. 我不认为所有设计在所有浏览器中看起来都一样。 It's nearly impossible with the growing range of browsers and devices that must be supported, but I understand that things shouldn't break. 随着越来越多的浏览器和设备必须得到支持,这几乎是不可能的,但我知道事情不应该破坏。

This might require a case-to-case basis, but some things to look into are: 这可能需要个案基础,但有些事情需要研究:

  1. Use HTML5 Shiv so IE browsers can recognize HTML5 elements: http://code.google.com/p/html5shiv/ 使用HTML5 Shiv,以便IE浏览器可以识别HTML5元素: http//code.google.com/p/html5shiv/
  2. You could also look into HTML5 Boilerplate but that could be overkill http://html5boilerplate.com/ 您也可以查看HTML5 Boilerplate,但这可能是过度杀手http://html5boilerplate.com/
  3. In the design process, make sure any CSS3 properties are not so critical to design that they break it. 在设计过程中,确保任何CSS3属性都不是那么重要,因为它们会破坏它们。

显然你必须为每种特定类型的浏览器调整设计。

使用CSS框架(如http://twitter.github.com/bootstrap/http://documentcloud.github.com/backbone/)肯定可以帮助完成此过程。

如果你开始使用CSS重置 (这是另一个 )或一些HTML样板,你至少可以减少使用不同浏览器的大部分奇怪之处。

Grab Modernizr for a start, which uses selectivizr I believe! 抓住Modernizr开始,我相信使用选择性

For Li's I would use 对于李,我会用

li{
  display: inline-block; //NO Floats
  *display: inline; /* < target IE7 */
  *zoom:1;
}

Double margins: fix those with IE conditional stylesheet OR html5boilerplate 双边距:用IE条件样式表或html5boilerplate修复

Most other elements would depend on display type 大多数其他元素将取决于display类型

For CSS3 maybe use CSSPie 对于CSS3,也许可以使用CSSPie

Clears: 清除:

:after{
    content: '.';
    clear:both;
    visibility: hidden;
    *zoom:1;
    height:0;
    display:block;
 }

Some of the other issue's are fixed quite easily! 其他一些问题很容易修复!

For screen width's use % instead of PX for greater control 对于屏幕宽度,使用%代替PX以获得更好的控制

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM