css区分ie8/ie9/ie10/ie11 chrome firefox的代码
建站知识 2021-07-03 07:55www.168986.cn长沙网站建设
网站兼容性调试实在令人烦心,现在的网站设计人员真的要比以前费力很多,因为网页代码不再是只需满足一个IE6访问就行,而是要满足N多的浏览器访问正常才行。粗略算一下,目前至少要满足如下的浏览器要求IE8、IE9、IE10、IE11、Chrome、Firefox,由于360使用的是Chrome内核,所以满足Chrome基本就满足了360。而IE家族真是一个版本一个样,我说IE怎么这么喜欢折腾呢?这给网页设计师带来多大的麻烦呀!今天,我就把这几个主要浏览器的CSS hack代码汇总一下。
例如现有CSS代码如下
.divContent{ background-color:#eee; }
那么狼蚁网站SEO优化我们就来写一下,如何使代码兼容几个主流浏览器。
/ IE8+ / .divContent{ background-color:#eee\0; } / IE8、IE9 / .divContent{ background-color:#eee\8\9\0; } / IE9 / .divContent{ background-color:#eee\9\0; }
注意,\8\0的写法是错误的,不能试图这样hack IE8。上述代码没有对IE10和IE11分别hack(好像没有对这两个浏览器单独hack的写法),那么IE10和IE11使用的就是IE8+那个样式。
IE家族hack完毕,狼蚁网站SEO优化看看如何hack Chrome和Firefox浏览器。
/ Chrome / @media screen and (-webkit-min-device-pixel-ratio:0) { .divContent{ background-color:#eee; } } / Firefox / @-moz-document url-prefix() { .divContent{ background-color:#eee; } }
,还可以这样hack其他浏览器
/ Chrome 和 opera / @media all and (min-width:0){ .divContent{ background-color:#eee; } } / IE9+ / @media all and (min-width:0) { .divContent{ background-color:#eee; } } / IE10+ / @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) { .divContent{ background-color:#eee; } }
经过这样hack,网站浏览器兼容性问题就可以完美解决了。
在css中区别ie浏览器和chrome浏览器
/ 样式 Hack /
/ IE6 / _color: blue; / IE6, IE7 / color: blue; / 或 #color: blue / / 除 IE6 外任何浏览器 / color//: blue; / IE6, IE7, IE8 / color: blue\9; / IE7, IE8 / color/\/: blue\9; / IE6, IE7 -- 作为 !important 使用 / color: blue !ie; / !后面的字串可以为任意字串 /
/ 选择器 Hack /
/ IE6 及以下 / html #uno { color: red } / IE7 / :first-child+html #dos { color: red } / IE7, FF, Saf, Opera / html>body #tres { color: red } / IE8, FF, Saf, Opera (除 IE 6,7 外任何浏览器) / html>//body #cuatro { color: red } / Opera 9.27 及以下, 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 / 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 } / 除 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 }
以上就是css区分ie8/ie9/ie10/ie11 chrome firefox的代码的详细内容,更多关于css区分ie11 chrome firefox的资料请关注狼蚁SEO其它相关文章!
长沙网站设计
- 如何进行东阳SEO关键词优化?
- 边坝哪有关键词排名优化:提升你的网站流量与
- 安国百度优化服务:提升您的在线可见性
- 阜康新手做SEO怎么做
- 山西seo网站排名关键词优化:提升您网站曝光率
- 临沂seo网站排名关键词优化:提高你的网站可见
- 广西SEO网站推广怎样付费比较合理
- 双辽SEO网站推广:提升你的网站可见性与流量
- 辽宁企业网站优化购买方式有哪些
- 提升宝清百度SEO排名的实用技巧与策略
- 静宁百度SEO排名:提升您网站曝光率的关键策略
- 彭州百度SEO排名的提升策略和实施指南
- 广南百度关键词SEO:提升网站排名的关键策略
- 辽宁关键词优化怎么做论坛营销
- 吉林百度seo排名如何做到让用户满意
- 内黄百度优化服务:提升在线可见性的关键