CSS 如何获取css版本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4440868/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to get the css version
提问by Sachindra
How do i get the version of CSS that I am using?
如何获取我正在使用的 CSS 版本?
回答by Spudley
Although the CSS specification is defined in several versions (v2, 2.1, 3), the CSS version isn't really relevant to the developer; you need to be more concerned with which web browsers support a given feature.
尽管 CSS 规范在多个版本(v2、2.1、3)中进行了定义,但 CSS 版本与开发人员并没有真正的相关性;您需要更加关注哪些 Web 浏览器支持给定的功能。
It is useful to know that a given feature was defined in CSS2, 2.1 or 3 because that can give you an idea of how old the feature is, and therefore how likely it is that browsers will support it -- for example border-radius
is a CSS3 feature, so browsers more than a couple of years old may not support it fully.
知道一个给定的功能是在 CSS2、2.1 或 3 中定义的,这很有用,因为这可以让您了解该功能的历史,以及浏览器支持它的可能性——例如border-radius
是 CSS3 功能,所以几年前的浏览器可能无法完全支持它。
You can find out what CSS features are supported in which browsers from the following sites:
您可以从以下站点了解哪些浏览器支持哪些 CSS 功能:
Hope that helps.
希望有帮助。
回答by Craig
The version is only defined by the CSS selectors, propreties and attributes that you use.
版本仅由您使用的 CSS 选择器、属性和属性定义。
You are free to mix elements of CSS 1, 2 and 3 in any styles that you write.
您可以在您编写的任何样式中自由混合 CSS 1、2 和 3 的元素。
You can refer to the CSS specifications to see more details. The specifications and drafts at the W3C is available via this index: http://www.w3schools.com/w3c/w3c_css.asp
您可以参考 CSS 规范以查看更多详细信息。W3C 的规范和草案可通过以下索引获得:http: //www.w3schools.com/w3c/w3c_css.asp
回答by Jorge
Just an addition of what @Craig said.
只是@Craig所说的补充。
In my .net 2.0 framework I have a property to show scroll bars. As I want just the vertical, I've added both properties and, if the browser that user is using support this new CSS 3.0 property (overflow-x), he will see just the vertical one.
在我的 .net 2.0 框架中,我有一个属性来显示滚动条。因为我只想要垂直,所以我添加了这两个属性,如果用户使用的浏览器支持这个新的 CSS 3.0 属性 ( overflow-x),他将只看到垂直属性。
回答by Brent Wilson
As far as I know there's nothing in CSS code that specifies the version. Browsers are designed to interpret one or more versions of CSS at runtime. Therefore, I would imagine that you would need to get the verion of the browser via javascriptand then determine what version of CSS is understood by the browser.
据我所知,CSS 代码中没有任何内容指定版本。浏览器旨在在运行时解释一个或多个版本的 CSS。因此,我认为您需要通过 javascript 获取浏览器的版本,然后确定浏览器理解的 CSS 版本。
回答by Knu
In my opinion you should use object detectioninstead - check the MDCto understand the principle.
On Internet Explorer you might find compatModeand documentModeuseful.
在我看来,您应该改用对象检测- 检查MDC以了解原理。
在 Internet Explorer 上,您可能会发现compatMode和documentMode很有用。