CSS类的层次结构差异 [英] CSS class hierarchy difference

查看:83
本文介绍了CSS类的层次结构差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个基本的CSS问题.我想知道这两个类之间的区别.
和有什么不一样 下例中的fieldset.login标签和fieldset label.login吗?

Hi,

I have a basic CSS question. I would like to know the difference between these two blocks of classes. What''s the difference between
fieldset.login label and fieldset label.login in the example below ?

fieldset.login label
{
    display: block;
}

fieldset label.login
{
    display: inline;
}

推荐答案

第一个是通用的,第二个是通用的.对于第一个,将称为登录的字段集类应用于该字段集中的所有标签,而在第二个字段中,只有在该字段集中具有登录类的标签才会应用该类.完全可以确定.
The first is generic, the second specific. For the first a fieldset class called login is applied to all labels within the fieldset whereas in the second only labels with a class of login within the fieldset will have the class applied. Fairly sure that''s it.


区别是:

这会将display:block;分配给类"login"的字段集中包含的所有标签

The difference is:

this assigns display:block; to all labels contained within fieldsets with class "login"

fieldset.login label
{
    display: block;
}



而这会将display:inline;分配给所有字段集中包含的所有带有登录"类的标签



whereas this assigns display:inline; to all labels with class "login" contained within all fieldsets

fieldset label.login
{
    display: inline;
}


您好

以上解释是正确的.也尝试使用此直观示例以了解清楚.

CSS ..

Hi

The above explanations are correct. Try this visual example as well to understand clear.

the CSS..

fieldset.login label
{
    color:Blue;
}
fieldset label.login
{
    color:Green;
}



HTML ...



the HTML...

<fieldset>
   <label class="login">It is login class on the label</label>
 </fieldset>
     <fieldset class="login">
            <label >It is login class in the FieldSet</label>
 </fieldset>



这个例子很容易解释



This example is self explainable


这篇关于CSS类的层次结构差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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