2013-11-22 59 views
1

我在輸入類型按鈕上應用背景圖片。爲此,我在style.css中編寫了我的代碼。但是現在我希望該按鈕看起來像是默認的,但是我的限制是我無法從style.css中刪除css樣式。但我可以覆蓋它在其他CSS style1.css。 所以我怎麼能重寫這個?設置輸入類型按鈕的默認css

的style.css

button 
{ 
background:red; 
} 

如果我重寫這樣就顯示什麼。

style1.css

button 
{ 
background:none; 
} 
+0

http://stackoverflow.com/questions/381100/reverting-css-style-of-input-type-submit-button-to-its-default-style –

回答

0

您可以使用內聯樣式,或使用!important

例子:

style1.css

button 
    { 
     background:none !important; 
    } 

或內聯:

<button style="background: none;"> 
+0

請不要在CSS中使用'!important',這是非常糟糕的做法。 –

0

你可以做這樣的...

button { background:none !important; } 
+0

我必須設置按鈕的默認外觀(看起來像Windows製造),像你的做不會工作:( –

3

可能重複的問題爲Can you style html form buttons with css?

嘛,只要按鈕或其他任何輸入類型被認爲是你可以做,通過添加此:

HTML

<input type="submit" name="submit" value="Submit Application" id="submit" /> 

CSS

#submit { 
    background-color: #ccc; 
    -moz-border-radius: 5px; 
    -webkit-border-radius: 5px; 
    border-radius:6px; 
    color: #fff; 
    font-family: 'Oswald'; 
    font-size: 20px; 
    text-decoration: none; 
    cursor: poiner; 
    border:none; 
} 



#submit:hover { 
    border: none; 
    background:red; 
    box-shadow: 0px 0px 1px #777; 

} 

你甚至可以試試這個,

input[type="submit"]{ 
    background: #fff; 
    border: 1px solid #000; 
    text-shadow: 1px 1px 1px #000; 
} 

,甚至,你可以添加一個類:

.my_button_type 
{ 
    background: #fff; 
    border: 1px solid #000; 
    text-shadow: 1px 1px 1px #000; 
} 

您也可以申請聯樣式:

<input type="button" style="background: #333; border: 0px;" /> 

所以,你有很多方法可以做到這一點。

0

首先,優先級是很重要的:

<link rel="stylesheet" href="style.css" /> 
<link rel="stylesheet" href="style1.css" /> 

你必須把css文件要覆蓋原來的css後。

其次,在你的style1.css,有這麼多的方法來實現你想要的。像抵消要覆蓋

//style.css 
button { 
    background: url("..."); 
} 

//style1.css 
button { 
    background: none; 
} 

或使用!important到要實現屬性的CSS樣式。