什么是“>”,是什么意思在CSS? [英] What does ">" mean in CSS?

查看:1632
本文介绍了什么是“>”,是什么意思在CSS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

什么是">是什么意思在CSS规则?


; 在CSS中的符号意味着什么?我注意到它在我的Wordpress博客主题,想知道它在做什么。

  #access li:hover> a,
#access ul ul:hover> a,
#access a:focus {
background:#efefef;
}
#access li:hover> a,
#access a:focus {
background:#f9f9f9; / *为旧浏览器显示纯色* /
背景:-moz-linear-gradient(#f9f9f9,#e5e5e5);
background:-o-linear-gradient(#f9f9f9,#e5e5e5);
background:-webkit-gradient(线性,0%0%,0%100%,从(#f9f9f9)到(#e5e5e5)); / *旧版webkit语法* /
background:-webkit-linear-gradient(#f9f9f9,#e5e5e5);
color:#373737;
}
#access ul li:hover> ul {
display:block;
}


解决方案

嵌套元素将被定位(子元素),例如

 < div id =a> 
< div id =b>
< div id =c>
< / div>
< / div>
< / div>

  #a div {
background:red;
}

那么#b和#c将会是红色,喜欢

  #a> div {
background:red;
}

那么只有#b会是红色,#c不会。 >

Possible Duplicate:
What does “>” mean in CSS rules?

What does the > symbol mean in CSS? I noticed it in my Wordpress blog theme and want to know what it is doing.

#access li:hover > a,
#access ul ul :hover > a,
#access a:focus {
    background: #efefef;
}
#access li:hover > a,
#access a:focus {
    background: #f9f9f9; /* Show a solid color for older browsers */
    background: -moz-linear-gradient(#f9f9f9, #e5e5e5);
    background: -o-linear-gradient(#f9f9f9, #e5e5e5);
    background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#f9f9f9), to(#e5e5e5)); /* Older webkit syntax */
    background: -webkit-linear-gradient(#f9f9f9, #e5e5e5);
    color: #373737;
}
#access ul li:hover > ul {
    display: block;
}

解决方案

it means that only "first nested" elements will be targeted ("child" elements), for example

   <div id="a">
       <div id="b">
         <div id="c">
       </div>
      </div>
    </div>

if you write

#a div{
 background: red;
}

then both #b and #c will be red, but if you use > like

#a > div{
 background: red;
}

then only #b will be red, #c will not.

这篇关于什么是“&gt;”,是什么意思在CSS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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