程序问答   发布时间:2022-06-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了如何为Mozilla,Chrome和IE编写特定的CSS大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决如何为Mozilla,Chrome和IE编写特定的CSS?

开发过程中遇到如何为Mozilla,Chrome和IE编写特定的CSS的问题如何解决?下面主要结合日常开发的经验,给出你关于如何为Mozilla,Chrome和IE编写特定的CSS的解决方法建议,希望对你解决如何为Mozilla,Chrome和IE编写特定的CSS有所启发或帮助;

为了那个原因

  • 您可以扫描用户代理并找出哪个浏览器及其版本。包括适用于特定于操作系统样式的操作系统
  • 您可以为特定的浏览器使用各种CSS技巧
  • 或脚本或插件来识别浏览器并将各种类应用于元素

使用php

然后根据检测到的浏览器创建动态CSS文件

这是CSS骇客清单

/***** SELEctor Hacks ******/

/* ie6 and below */
* HTML #uno  { color: red }

/* ie7 */
*:first-child+HTML #dos { color: red }

/* ie7, FF, Saf, Opera  */
HTML>body #tres { color: red }

/* ie8, FF, Saf, Opera (Everything but IE 6,7) */
HTML>/**/body #cuatro { color: red }

/* Opera 9.27 and below, safari 2 */
HTML:first-child #cinco { color: red }

/* Safari 2-3 */
HTML[xmlns*=""] body:last-child #seis { color: red }

/* safari 3+, Chrome 1+, opera9+, ff 3.5+ */
body:nth-of-type(1) #sIEte { color: red }

/* safari 3+, Chrome 1+, opera9+, ff 3.5+ */
body:first-of-type #ocho {  color: red }

/* saf3+, Chrome1+ */
@media screen and (-webkit-min-device-pixel-ratio:0) {
 #dIEz  { color: red  }
}

/* iPhone / mobile webkit */
@media screen and (max-device-wIDth: 480pX) {
 #veintiseis { color: red  }
}


/* Safari 2 - 3.1 */
HTML[xmlns*=""]:root #trece  { color: red  }

/* Safari 2 - 3.1, Opera 9.25 */
*|HTML[xmlns*=""] #catorce { color: red  }

/* Everything but ie6-8 */
:root *> #quince { color: red  }

/* ie7 */
*+HTML #dIEciocho {  color: red }

/* firefox only. 1+ */
#veinticuatro,  x:-moz-any-link  { color: red }

/* firefox 3.0+ */
#veinticinco,  x:-moz-any-link, x:default  { color: red  }



/***** Attribute Hacks ******/

/* ie6 */
#once { _color: blue }

/* ie6, ie7 */
#doce { *color: blue; /* or #color: blue */ }

/* Everything but ie6 */
#dIEcisIEte { color/**/: blue }

/* ie6, ie7, ie8 */
#dIEcinueve { color: blue\9; }

/* ie7, ie8 */
#veinte { color/*\**/: blue\9; }

/* ie6, ie7 -- acts as an !important */
#veintesIEte { color: blue !IE; } /* String after ! can be anything */

解决方法

您可以使用CSS条件语句包含针对IE,Mozilla,Chrome的特定CSS。

If IE  
#container { top: 5px; }

If Mozilla 
#container { top: 7px; }

If Chrome  
#container { top: 9px; }

相应的“如果”是什么?

大佬总结

以上是大佬教程为你收集整理的如何为Mozilla,Chrome和IE编写特定的CSS全部内容,希望文章能够帮你解决如何为Mozilla,Chrome和IE编写特定的CSS所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。