在元素中使用样式和类 [英] using both style and class in an element

查看:50
本文介绍了在元素中使用样式和类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨伙计们,


我在一些页面中发现了这个:


< td style =" border-bottom:1px solid #000000; border-left:1px solid

#000000; background-color:#4080A0; font-weight:bold;颜色:#000000;"

class =" myclass">


我从未见过同一元素中使用的样式和类。

常见吗?哪个胜利?会发生什么?


对于它的价值,类myclass实际上没有被定义。

-

Dan Langille

履历表: http://www.langille.org/

Hi folks,

I found this in some pages:

<td style="border-bottom: 1px solid #000000; border-left: 1px solid
#000000; background-color:#4080A0;font-weight: bold; color: #000000;"
class="myclass">

I''ve never seen both style and class used in the same element. Is the
common? Which wins? What happens?

For what it''s worth, the class myclass was not actually defined.
--
Dan Langille
resume: http://www.langille.org/

推荐答案

Dan Langille写道:
Dan Langille wrote:
我从未见过使用的样式和类在同一个元素中。
常见吗?


不,谢天谢地。风格属性令人讨厌。

哪个胜利?会发生什么?
I''ve never seen both style and class used in the same element. Is the
common?
No, thankfully. The style attribute is nasty.
Which wins? What happens?




样式属性比外部样式表具有更高的特异性。


-

David Dorward http://david.us-lot.org/

重新设计正在进行中: http://stone.thecoreworlds.net/

微软宣布IE已经死亡(所以升级):
http://minutillo.com/steve/weblog/20...ces-ie-is-dead



The style attribute has a higher specificity then external style sheets.

--
David Dorward http://david.us-lot.org/
Redesign in progress: http://stone.thecoreworlds.net/
Microsoft announces IE is dead (so upgrade):
http://minutillo.com/steve/weblog/20...ces-ie-is-dead


" Dan Langille" <我们****** @ YEAH.RIGHT.dvl-software.com.invalid>写在

消息新闻:c5 ******************************** @ 4ax.com ...
"Dan Langille" <us******@YEAH.RIGHT.dvl-software.com.invalid> wrote in
message news:c5********************************@4ax.com...
嗨伙计们,

我在一些页面中发现了这个:

< td style =" border-bottom:1px solid #000000; border-left:1px solid
#000000; background-color:#4080A0; font-weight:bold; color:#000000;"
class =" myclass">

我从未见过同一元素中使用的样式和类。
常见吗?哪个胜利?会发生什么?
Hi folks,

I found this in some pages:

<td style="border-bottom: 1px solid #000000; border-left: 1px solid
#000000; background-color:#4080A0;font-weight: bold; color: #000000;"
class="myclass">

I''ve never seen both style and class used in the same element. Is the
common? Which wins? What happens?




这就是级联的地方。规则发挥作用。 ID比CL $更重,但本地定义的样式比链接更重要

样式表,定义的样式的最后一个实例覆盖以前的

实例等等。


- Richard



This is where the "cascade" rules come into play. IDs have more weight than
CLASSes, but locally-defined styles have more weight than linked
stylesheets, the last instance of style defined overrides a previous
instance, etc., etc.

-- Richard


David Dorward< do ***** @ yahoo.com>写道:
David Dorward <do*****@yahoo.com> wrote:
我从未见过同一元素中使用的样式和类。
常见吗?
I''ve never seen both style and class used in the same element. Is the
common?


哪个获胜?会发生什么?
Which wins? What happens?



style属性比外部样式表具有更高的特异性。



The style attribute has a higher specificity then external style sheets.




不一定,ID''在外部样式表中具有比内联样式更高的b $ b特异性。

无头



Not necessarily, ID''s in an external stylesheet have a higher
specificity than an inline style.
Headless


这篇关于在元素中使用样式和类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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