{"_id":"cssuseragent","_rev":"3-d8240db7c118ac860bfcf7b3f6c2f62f","name":"cssuseragent","description":"Automatically adds UserAgent-specific CSS classes to the document allowing for browser variations without resorting to CSS hacks.","dist-tags":{"latest":"2.1.31"},"versions":{"2.1.31":{"name":"cssuseragent","version":"2.1.31","description":"Automatically adds UserAgent-specific CSS classes to the document allowing for browser variations without resorting to CSS hacks.","homepage":"http://cssuseragent.org","author":{"name":"Stephen McKamey","url":"http://mck.me"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/mckamey/cssuseragent.git"},"files":["cssua.js","README.md","LICENSE.txt"],"main":"cssua.js","keywords":["cssuseragent","cssua","css","useragent"],"gitHead":"36498fc10f09a0076561d251021ffc11ef994de5","bugs":{"url":"https://github.com/mckamey/cssuseragent/issues"},"_id":"cssuseragent@2.1.31","scripts":{},"_shasum":"bbb6e5695e5a5f1b80c898af933a87087b30ba3e","_from":".","_npmVersion":"2.11.2","_nodeVersion":"0.12.5","_npmUser":{"name":"mckamey","email":"stephen@mckamey.com"},"dist":{"shasum":"bbb6e5695e5a5f1b80c898af933a87087b30ba3e","tarball":"https://registry.npmjs.org/cssuseragent/-/cssuseragent-2.1.31.tgz","integrity":"sha512-5SAbwXCyXdYQlxR35C/eW4TnhAmHrf9Q58BtXttfr/6pmucXl7BWfuy2qtIrf/F+jzkRqiCixZyaNFtqn6Oi+g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIH/h12yp/IPw7Quo3mKwrQzhWV2nwIdhVeh5KavPaC7sAiBM3SPCIQsms3T5dsgP3KezZ+Lotfcf9tC51RIoiGAfVw=="}]},"maintainers":[{"name":"mckamey","email":"stephen@mckamey.com"}]}},"readme":"# [.css{user:agent;}][1]\r\nDistributed under the terms of [The MIT license][2].\r\n\r\n## Special CSS Classes...\r\n\r\nAdding cssua.js to the page preps the document with special CSS classes which enable targeting of browsers with varying degrees of precision.\r\n\r\n\t<!-- example CSS classes applied to the page -->\r\n\t<html class=\"ua-chrome ua-chrome-25 ua-chrome-25-0 ua-chrome-25-0-1364 ua-chrome-25-0-1364-172\r\n\t\tua-desktop ua-desktop-macintosh\r\n\t\tua-mac_os_x ua-mac_os_x-10 ua-mac_os_x-10-8 ua-mac_os_x-10-8-3\r\n\t\tua-webkit ua-webkit-537 ua-webkit-537-22\">\r\n\t\t...\r\n\t</html>\r\n\r\n## UserAgent map...\r\n\r\nUserAgent-sniffing is regarded as something to be used sparingly, but pragmatic developers know it is\r\nsometimes the simplest approach to fixing a particular browser's quirk. When it is, cssua.js produces\r\na helper object as a side-effect which makes user-agent-siffing easier and more consistent.\r\n\r\nAn object map is also built which allows you to test the user agent from your script in a simplified\r\nmanner that doesn't require string parsing. For example, this object is effectively produced:\r\n\r\n\tcssua.userAgent = cssua.ua = {\r\n\t\tchrome: \"25.0.1364.172\",\r\n\t\tdesktop: \"macintosh\",\r\n\t\tmac_os_x: \"10.8.3\",\r\n\t\twebkit: \"537.22\"\r\n\t};\r\n\r\n## Examples\r\n\r\nThis makes applying slight layout differences a snap:\r\n\r\n\t/* CssUserAgent lets you target specific browsers without resorting CSS hacks */\r\n\t.foo\r\n\t{\r\n\t\tbackground-image: url(foo.png);\r\n\t\tbackground-repeat: no-repeat;\r\n\t\tbackground-position: left top;\r\n\t}\r\n\r\n\t.ua-ie-5 .foo,\r\n\t.ua-ie-6 .foo\r\n\t{\r\n\t\t/* IE versions < 7.0 don't fully support transparent 24-bit PNGs */\r\n\t\tbackground-image: url(foo.gif);\r\n\t}\r\n\r\nTesting for older Internet Explorer has never been easier than\r\n\r\n\tif (cssua.userAgent.ie < 8) { /* proof of Pareto principle here */ }\r\n\r\nOr testing if is a mobile browser:\r\n\r\n\tif (cssua.userAgent.mobile) { /* consider your audience */ }\r\n\r\nRemember to convert a version `String` to a `Number` with `parseFloat` if the value isn't a simple number,\r\ne.g., it has multiple decimal points or trailing letters. Otherwise, JavaScript may interpret\r\nthe value as `NaN` (not-a-number):\r\n\r\n\tif (parseFloat(cssua.ua.chrome) > 101) { /* enter the Matrix */ }\r\n\r\n## Mobile browser detection\r\n\r\nCssUserAgent helps detect the increasingly ambiguous category of mobile browsers.\r\ncssua.js adds specific classes when it detects mobile browsers:\r\n\r\n\t<html class=\"... ua-mobile ua-mobile-iphone ...\">...<html>\r\n\r\n## No Browser Hacks...\r\n\r\nThis technique also avoids *all* CSS hacks. It allows you to target the browser rendering engine\r\n(e.g. \"ua-gecko\"), or a specific browser (e.g. \"ua-firefox\"). The version can be targeted at the major version\r\nnumber (e.g. \"ua-ie-5\" includes 5.0, 5.5) or minor (e.g. \"ua-ie-5-0\" includes only 5.0) all the way down\r\nto a very specific case (e.g. \"ua-chrome-8-0-552-224\").\r\n\r\n## Future UserAgents...\r\n\r\nThis script understands the common structures of user agent strings enabling future user agent strings to simply\r\nwork without changes. For example, when the early beta builds of Google Chrome were first released,\r\nit just worked.\r\n\r\n----\r\n\r\nTested with   \r\n[![BrowserStack](./test/styles/browsers/BrowserStack_128.png)](http://www.browserstack.com)\r\n\r\n----\r\n\r\nCopyright (c) 2006-2013 Stephen M. McKamey\r\n\r\n  [1]: http://cssuseragent.org\r\n  [2]: https://raw.githubusercontent.com/mckamey/cssuseragent/master/LICENSE.txt\r\n","maintainers":[{"name":"mckamey","email":"stephen@mckamey.com"}],"time":{"modified":"2022-06-14T05:12:41.884Z","created":"2016-01-19T04:28:13.725Z","2.1.31":"2016-01-19T04:28:13.725Z"},"homepage":"http://cssuseragent.org","keywords":["cssuseragent","cssua","css","useragent"],"repository":{"type":"git","url":"git+https://github.com/mckamey/cssuseragent.git"},"author":{"name":"Stephen McKamey","url":"http://mck.me"},"bugs":{"url":"https://github.com/mckamey/cssuseragent/issues"},"license":"MIT","readmeFilename":"README.md"}