简评: 浏览器兼容性问题常常让人头疼,以下是避免出现这些问题的五个技巧。1. 前缀 CSS3 样式如果您正在使用任何类型的现代 CSS 片段,例如框尺寸(box-sizing)或背景剪辑(background-clip),请确保使用适当的前缀。
-moz- /* Firefox and other browsers using Mozilla's browser engine */-webkit- /* Safari, Chrome and browsers using the Webkit engine */-o- /* Opera */-ms- /* Internet Explorer (but not always) */2. 使用 reset您可以使用 normalize.css,下面是我用的,来自 Genesis Framework Style Sheet。
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,a,abbr,acronym,address,big,cite,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,input,menu,nav,output,ruby,section,summary,time,mark,audio,video {border: 0;margin: 0;padding: 0;vertical-align: baseline;}3. 避免填充宽度当你添加宽度为一个元素的填充时,它会变得更大。宽度和填充将被加在一起。
要解决这个问题,可以添加这个:
* { -webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */-moz-box-sizing: border-box; /* Firefox, other Gecko */box-sizing: border-box; }4. 清除 float如果没有清除,很容易出问题。感兴趣的可以看看 Chris Coyier 的这篇文章。
...