crucifyer / css-browser-selector
CSS 浏览器选择器 - 无需 CSS 修复。为 HTML 标签添加浏览器信息
dev-master
2022-06-06 06:52 UTC
Requires
- php: >=5.2.4
This package is auto-updated.
Last update: 2024-09-06 11:54:38 UTC
README
随着 IE 已成往事,这个库不再需要。
无需 CSS 修复。从 http://rafael.adm.br/css_browser_selector/ 分支此项目
如果 IE6
<html class="ie ie6 win js">
- ie6 ie67 ie678 ie6789
如果 IE10
<html class="ie ie10 ie9m win js">
如果 EDGE
<html class="chrome edge win js"> <html class="ie ie12 ie9m edge win js" oldedge>
如果 iPhone Safari
<html class="webkit safari mobile ios iphone js">
如果 android retina tablet chrome
<!-- android default internet browser --> <html class="webkit chrome mobile chromedef android tablet retina ratio2 js"> <!-- google play chrome browser --> <html class="webkit mobile chrome android tablet retina ratio2 js">
使用
.myText { margin-bottom:2px; } .ie6 .myText { margin-bottom:1px; } .opera .myText { margin-top:-1px; }
使用的 PHP 版本
$className = css_browser_selector::getClassName($_SERVER['HTTP_USER_AGENT']);
更多支持类型
.ie67, .ie678, .ie9m (IE9 and more) .ff4 ~ .ff11 and more
如果 jQuery 且支持移动设备
width > height ? landscape : portrait
.portrait .landscape .smartnarrow ( <= 360 ) .smartwide ( <= 640 ) .tabletnarrow ( <= 768 ) .tabletwide ( <= 1024 ) .pc ( > 1024 )
示例
#photo { float:left; } .iphone.portrait #photo { clear:both; } .smartwide #leftMenu, .tabletwide #leftMenu { float:left; width:120px; } .tabletwide #rightMenu { float:right; width:120px; }
- 支持视网膜屏:查看测试页面。 https://crucifyer.github.io/css-browser-selector/
移动字体缩放禁用
body { -webkit-text-size-adjust: none; -moz-text-size-adjust: none; -ms-text-size-adjust: none; text-size-adjust: none; }
jQuery 1.9 $.browser 已弃用。
// window.CSSBS_* defined. if(window.CSSBS_ie) alert('MSIE'); if(window.CSSBS_ie6) alert('MSIE 6'); if MSIE define $.browser = {msie:1,version:msie version}; other browser $.browser = {};
压缩版
源码
- https://raw.githubusercontent.com/crucifyer/css-browser-selector/master/css_browser_selector.js
- https://raw.githubusercontent.com/crucifyer/css-browser-selector/master/css_browser_selector.class.php
测试页面