2016-01-20 91 views
1

我有关于逗号分隔的CSS类的奇怪问题。火狐忽略了下面的类.Control-fakeSelect::after: - See resultFirefox忽略CSS逗号分隔的类

.Control-field::-webkit-calendar-picker-indicator, 
.Control-fakeSelect::after{ 
    background-color: transparent; /* 1 */ 
    background-image: url("data:image/svg+xml;utf8,%3Csvg%20width%3D%2215%22%20height%3D%229%22%20viewBox%3D%220%200%2015%209%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cg%20fill%3D%22none%22%20fill-rule%3D%22evenodd%22%3E%3Cg%20fill%3D%22%23444%22%3E%3Cpath%20d%3D%22M11.773.583L7.38%204.976%202.987.583C2.432.028%201.532.028.977.583c-.555.555-.555%201.455%200%202.01L6.374%207.99c.28.278.642.417%201.006.417.09%200%20.182-.01.27-.026.27-.05.526-.18.734-.39l5.4-5.397c.554-.555.554-1.455%200-2.01-.556-.555-1.456-.555-2.01%200z%22%2F%3E%3C%2Fg%3E%3C%2Fg%3E%3C%2Fsvg%3E"); 
    background-position: center right; 
    background-repeat: no-repeat; 
    color: transparent; /* 1 */ 
    content: ""; 
    cursor: pointer; 
    height: 15px; 
    line-height: 15px; 
    margin-top: 2px; 
    opacity: 1; /* 1 */ 
    padding: 10px 0 10px 20px; 
    position: absolute; 
    right: 0; 
    top: 50%; 
    transform: translateY(-50%); 
    width: 15px; 
} 

但是,如果我从逗号分隔的列表中删除.Control-field::-webkit-calendar-picker-indicator这样的CSS是这样的:

.Control-fakeSelect::after{ 
    background-color: transparent; /* 1 */ 
    background-image: url("data:image/svg+xml;utf8,%3Csvg%20width%3D%2215%22%20height%3D%229%22%20viewBox%3D%220%200%2015%209%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cg%20fill%3D%22none%22%20fill-rule%3D%22evenodd%22%3E%3Cg%20fill%3D%22%23444%22%3E%3Cpath%20d%3D%22M11.773.583L7.38%204.976%202.987.583C2.432.028%201.532.028.977.583c-.555.555-.555%201.455%200%202.01L6.374%207.99c.28.278.642.417%201.006.417.09%200%20.182-.01.27-.026.27-.05.526-.18.734-.39l5.4-5.397c.554-.555.554-1.455%200-2.01-.556-.555-1.456-.555-2.01%200z%22%2F%3E%3C%2Fg%3E%3C%2Fg%3E%3C%2Fsvg%3E"); 
    background-position: center right; 
    background-repeat: no-repeat; 
    color: transparent; /* 1 */ 
    content: ""; 
    cursor: pointer; 
    height: 15px; 
    line-height: 15px; 
    margin-top: 2px; 
    opacity: 1; /* 1 */ 
    padding: 10px 0 10px 20px; 
    position: absolute; 
    right: 0; 
    top: 50%; 
    transform: translateY(-50%); 
    width: 15px; 
} 

火狐认识到CSS类。 See result

之前有人遇到过这个问题,或者知道为什么Firefox忽略:: after添加到逗号分隔的css类之后?

回答

2

此行为是正确的和有意的。您的选择是:

.Control-field::-webkit-calendar-picker-indicator, 
.Control-fakeSelect::after 

火狐不能(也不会)解析第一个,因为它是特定的供应商,它认为整个规则原子无效的,因为它不知道如何充分应用它。 IE和Edge也会这样做。

所以,你的看法是错误的,它不涉及到:after或逗号,它涉及到-webkit前缀,这是故意和规格正确的行为。将规则拆分为2,它会正常工作。

+0

感谢@ niels-keurentjes,我不知道那个浏览器忽略它,因为它是供应商特定的。太糟糕了,但重复的CSS虽然:p – henrik123

+0

几年前,我发现了这种困难的方式,但它实际上是很好的行为,当你潜入它:) –