CSS按钮样式不 [英] CSS button not styling

查看:157
本文介绍了CSS按钮样式不的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,
 我一定是失去了一些东西很明显,但也有人解释我和我的CSS做错了什么?我想所有的按钮有一定的格式,除少数。我期待使用的CssClass 为了覆盖一些,应该是不同的,但他们似乎都使用的标准之一。

Hey, 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.

我的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

推荐答案

键入=按钮规则可能击败 BTN 特异性规则。你可以使用重要但不会在IE和LT工作!; 8势必会给长远来看问题。

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.

首先尝试此:

input[type="submit"].btn
    {

         border:none;
         background-color:red;

    }

这篇关于CSS按钮样式不的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆