对所有按钮使用现有样式,而不在类属性中指定它
我将 ASP.NET MVC 3 与 Razor 引擎以及最新版本的 Telerik MVC 控件一起使用。
在telerik.webblue.min.css
中有2种样式,即t-button
和t-state-default
。它是在这样的按钮元素上实现的:
<button class="t-button t-state-default" type="submit">Apply</button>
我不想使用类属性来指定要使用的样式,我想在我自己的样式表中指定所有按钮元素必须使用这两种样式。我在样式表中尝试了以下操作,但它不起作用:
button,.t-button,.t-state-default{}
所以我想要在标记中拥有的只是:
<button type="submit">Apply</button>
我将如何做到这一点?
更新
当我查看源代码时,我看到的是这样的:
<link href="/Assets/yui_2.9.0/yui/build/reset-fonts-grids/reset-fonts-grids.css" rel="stylesheet" type="text/css">
<link href="/Assets/telerikaspnetmvc/2011.2.712/Content/telerik.common.min.css" rel="stylesheet" type="text/css">
<link href="/Assets/telerikaspnetmvc/2011.2.712/Content/telerik.webblue.min.css" rel="stylesheet" type="text/css">
<link href="/Assets/Stylesheets/hbf.css" rel="stylesheet" type="text/css">
在 Firebug 中,当我选择该按钮时,它会显示该按钮最顶层的样式,如下所示:
button, .t-button, .t-state-default {
}
hbf.css (line 26)
I am using ASP.NET MVC 3 with the Razor engine together with the newest version of the Telerik MVC controls.
In telerik.webblue.min.css
there are 2 styles, namely t-button
and t-state-default
. It is implemented on a button element like this:
<button class="t-button t-state-default" type="submit">Apply</button>
I don't want to use a class attribute to specify which styles to use, I want to specify it in my own stylesheet that all button elements must use these 2 styles. I tried the folowing in my stylesheet but it doesn't work:
button,.t-button,.t-state-default{}
So all that I want to have in my markup is:
<button type="submit">Apply</button>
How would I do this?
UPDATE
When I view source this is what I see:
<link href="/Assets/yui_2.9.0/yui/build/reset-fonts-grids/reset-fonts-grids.css" rel="stylesheet" type="text/css">
<link href="/Assets/telerikaspnetmvc/2011.2.712/Content/telerik.common.min.css" rel="stylesheet" type="text/css">
<link href="/Assets/telerikaspnetmvc/2011.2.712/Content/telerik.webblue.min.css" rel="stylesheet" type="text/css">
<link href="/Assets/Stylesheets/hbf.css" rel="stylesheet" type="text/css">
In Firebug when I select the button it shows the top most style for this button as:
button, .t-button, .t-state-default {
}
hbf.css (line 26)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这应该有效。
中的所有样式放入
不过,您可以将
.t-button,.t-state-default {}
单个规则中
标记为
button {}
EDIT
我看到了问题。 (如果我理解正确的话)
这
出现在您的
hbf.css
中但是,它没有任何样式。
button
无法以这种方式引用其他样式。.t-button, .t-state-default
仍在接收来自telerik.webblue.min.css
样式表的样式。为了使其正常工作,您需要将
button
添加到telerik.webblue.min.css
样式表中。This should work.
However, you could place all the styles from
.t-button,.t-state-default {}
into a single rule labeled
button {}
EDIT
I think I see the problem, based on your update. (If I understand it correctly)
This
appears in your
hbf.css
However, it is styling nothing.
button
is not able to reference the other styles that way.The
.t-button, .t-state-default
are still receiving styles from thetelerik.webblue.min.css
stylesheet.In order to make it work, you need to add
button
to thetelerik.webblue.min.css
stylesheet.更新:
请参阅演示:http://jsfiddle.net/rathoreahsan/Q2JwE/
Updated:
See Demo: http://jsfiddle.net/rathoreahsan/Q2JwE/