CSS按钮不样式 [英] CSS button not styling
问题描述
我必须缺少一些明显的东西,但有人可以解释我做错了我的CSS吗?我想所有的按钮有一定的格式,除了几个。我期待使用 CssClass
以覆盖应该不同的少数,但他们似乎都使用标准的。
我的CSS:
.btn
{
border:none;
background-color:red;
}
input [type =submit]
{
border:2px solid black;
background-color:green;
}
所有按钮采用第二个值(绿色背景,带边框)。但是,我有这个按钮:
< asp:Button ID =btnAddCssClass =btnrunat = Text =Add/>
我希望这没有边框,红色的背景,但它是一样的
任何想法我做错了什么?
谢谢
type ='button'
可能会击败 btn
规则。你可以使用!important
但是在IE<
code> input [type =submit]。btn
{
border:none;
background-color:red;
}
I must be missing something obvious, but can someone explain what I'm doing wrong with my CSS? I would like all buttons to have a certain format, except a few. I was expecting to use CssClass
in order to override the few that should be different, but they all seem to use the standard one.
My CSS:
.btn
{
border:none;
background-color:red;
}
input[type="submit"]
{
border: 2px solid black;
background-color:green;
}
All the buttons take the second value (green background, with a border). However, I have this button:
<asp:Button ID="btnAdd" CssClass="btn" runat="server" Text="Add" />
I was expecting this to have no border, and a red background, but it's the same as every other button.
Any ideas what I'm doing wrong? Thanks
The type='button'
rule probably beats the btn
rule in specificity. You could use !important
but that won't work in IE < 8 and is bound to give problems in the long run.
Try this first:
input[type="submit"].btn
{
border:none;
background-color:red;
}
这篇关于CSS按钮不样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!