English 中文(简体)
为什么我不能为不同的浏览器分组特定浏览器的 CSS 选择器?
原标题:Why can I not group browser-specific CSS-selectors for different browsers?

我试图写下以下规则, 以对支持它的浏览器的输入占位符进行样式 :

#main input::-webkit-input-placeholder,
#main input:-moz-placeholder
{
    color: #888;
    font-style: italic;
}

问题在于这个规则并不适用。 但是,如果我这样分手,它就会很好地发挥作用:

#main input::-webkit-input-placeholder
{
    color: #888;
    font-style: italic;
}
#main input:-moz-placeholder
{
    color: #888;
    font-style: italic;
}

为什么我不能将特定浏览器的选择器分组, 或者有其他方法可以这样做? 重复相同元素两次相同的属性是不对的 。

<强> 更新:

刚刚找到< a href=> http://blogblog.ajcw.com/2011/02/styling-the-html5-placedusts/" rel="nofollow" > 这个资源 <\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

最佳回答

如果一组选择器中的一个选择器无效, 浏览器必须将整个规则视为无效 。 至少< a href=> http:// www.w3. org/ TR/ selectors/# grouping" rel=“ noreferrer” > 说 W3C

我不清楚为什么该行为被授权, 但是在按键时, 我想是因为一个无效的选择器可以打破 CSS 常规语法, 使浏览器无法可靠地猜测无效的选择器的终点和有效元素的起始位置 。

问题回答

最有可能的是,有些浏览器丢弃整个定义,因为他们认为选择器无效。

如果您愿意使用 JavaScript, 请查看无前缀脚本。 它允许您将类似 CSS 属性的特定前缀( 如 - Webkit- 或 - moz- ) 保存在销售商名下 。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

Drop down background url in Safari Issue

selectBox.selectCSS { background: url(/Images/replacementSelectBackground.png) top left no-repeat height:auto; } I have an issue in Safari only where the image is not rendering on top ...

CSS specific for Safari

How do you target specifically safari in css with styles?

Aligning textarea in a form

Ive used the following css code to align my form elements: form { position:relative; } form input { position:absolute; left:11em; } However, the textarea element is not aligned correctly with the ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

CSS problem with page footer

I have defined my page footer in the css file as: #footer { position: absolute; height: 50px; text-align: center; background: #66CCCC; bottom: 0px; left: 0px; width: 100%; height: ...

热门标签