为什么浏览器要为 CSS 属性创建供应商前缀? [英] Why do browsers create vendor prefixes for CSS properties?

查看:31
本文介绍了为什么浏览器要为 CSS 属性创建供应商前缀?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许这是一个显而易见的答案,但是

Maybe it's an obvious answer, but

为什么到底浏览器会决定为border-radius等创建自己的供应商前缀?

Why on earth would browsers decide to create their own vendor prefixes for border-radius and the like?

我的意思是:为什么我必须输入:

I mean: Why do I have to type:

-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;

是不是因为每个平台都认为我们很酷,我们会想出一个更好的方法来制作圆角?"为一行键入三行似乎完全且莫名其妙地多余.

Is it because each platform thought "We're cool, we'll come up with a better way to do rounded corners?" It seems totally and inexplicably redundant to type three lines for one.

推荐答案

这是因为在规范到达最终发布阶段之前,供应商已经实现了这些特性.

It's because the features were implemented by vendors before the specification reached its final release stage.

供应商前缀确保不会与不断变化的功能等发生冲突.

The vendor prefixes ensure that there are no clashes with changing functionality etc.

最初,供应商前缀的意义在于允许浏览器制造商开始支持实验性 CSS 声明.

Originally, the point of vendor prefixes was to allow browser makers to start supporting experimental CSS declarations.

假设 W3C 工作组正在讨论网格声明(其中,顺便说一句,这不是一个坏主意).再说说有些人创建了规范草案,但其他人不同意一些细节.我们知道,这个过程可能需要很长时间.

Let’s say a W3C working group is discussing a grid declaration (which, incidentally, wouldn’t be such a bad idea). Let’s furthermore say that some people create a draft specification, but others disagree with some of the details. As we know, this process may take ages.

再假设微软作为一个实验决定实施建议的网格.此时,微软不能确保规范不会改变.因此,相反将网格添加到其 CSS 中,它添加了 -ms-grid.

Let’s furthermore say that Microsoft as an experiment decides to implement the proposed grid. At this point in time, Microsoft cannot be certain that the specification will not change. Therefore, instead of adding grid to its CSS, it adds -ms-grid.

供应商前缀表示这是微软的解释正在进行的提案."因此,如果网格的最终定义是不同的是,微软可以在不破坏的情况下添加新的 CSS 属性网格依赖于 -ms-grid 的页面

The vendor prefix kind of says "this is the Microsoft interpretation of an ongoing proposal." Thus, if the final definition of grid is different, Microsoft can add a new CSS property grid without breaking pages that depend on -ms-grid

来源.

这篇关于为什么浏览器要为 CSS 属性创建供应商前缀?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆