2017-06-17 61 views
0

我的HTML文本輸入元素如下:input [type = text] Vs.類細節

<div class="form-group"> 
    <label>Ask</label> 
    <input type="text" name="ask_question" class="form-control" id="ask-question"> 
</div> 

有兩種樣式表「A」和「B」試圖修改此元素。

A被加載之前B.

A指定:

input[type=text] { 
    blah; 
    blah; 
} 

乙指定:

.form-control { 
    meh; 
    meh; 
} 

現在,瀏覽器顯示從樣式表中的 'A',而不是 'B' 的樣式。有什麼辦法可以忽略'A'並使用'B'的樣式?

注意:Stylesheet'B'實際上是bootstrap.min.css,它不指定屬性樣式,因此我無法覆蓋'A'的樣式。如果你能指出我正確的方向,我將不勝感激。謝謝!

+0

將'!important'添加到要在樣式表B中重寫的css規則應該解決您的問題 – sa77

回答

-1

使用!重要。這會強制規則覆蓋同一元素上的其他規則。

.form-control { 
    meh !important; 
    meh !important; 
} 
0

假設你不想編輯的B風格表,使規則更具體的,你可以編輯一個樣式表

一對夫婦的解決方法

[type=text] { /*drop specificity so last rule wins, i do not think type=text is used anywhere else*/ 
    blah; 
    blah; 
} 

input[type=text]:not(.form-control) { /*explicitly do not apply to .form-control*/ 
    blah; 
    blah; 
} 
相關問題