據我所知,類應該優先於元素樣式的樣式。我嘗試過設計button
,input[type=button]
和input[type=submit]
的樣式,並注意到使用input
(button
和submit
)時,元素的border
樣式優先於該類的border
樣式。但是,我沒有注意到這種行爲,但在button
元素上。CSS輸入(按鈕)邊框特定性
這裏的an example證明的情況:上述
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<style>
input[type=button], button {
border: none;
}
.class {
border: 1px solid red;
}
</style>
</head>
<body>
<input type="button" class="class" value="With class" />
<input type="button" value="Without class" />
<button class="class">With class</button>
</body>
</html>
呈現這樣的:
我注意到在Safari,火狐和Chrome相同的行爲。
我做錯了什麼?我是否誤解了這種情況下的特異性?這僅限於border
嗎?
添加[例子比較'蘋果蘋果'](http://jsfiddle.net/JVNZv/5/),也許? (編輯:添加更好的例子) – 0b10011
謝謝!我不知道屬性選擇器比元素選擇器有更高的特異性,我的不好! – alexcoco