代码之家  ›  专栏  ›  技术社区  ›  jo

在css中>是什么意思?

  •  20
  • jo  · 技术社区  · 15 年前

    在iui css文件中,它们使用以下选择器:

    body > *:not(.toolbar)
    body > *[selected="true"] 
    

    >、*:not()和*[]是什么意思?

    谢谢。

    4 回复  |  直到 10 年前
        1
  •  23
  •   Marc W    15 年前

    > 意味着“ is a child element of “。所以 body > *:not(.toolbar) 比赛 *:not(.toolbar) 那是一个孩子 body .

    *:(…工具栏) 匹配没有类的任何元素 .toolbar .

    *[selected="true"] 将任何元素与 selected 属性等于 true .

    记住最后两个( *:not() *[] 是其中的一部分 CSS3 spec 而且您通常不能依赖它们来实现跨浏览器的CSS兼容性。然而,它们在webkit中得到了充分的支持,而webkit正是iPhone(以及因此而产生的iUI)所使用的。

        2
  •  17
  •   Community PPrice    10 年前
    • > 指直系子女
    • * 是通用选择器(所有内容)
    • :not() 除了括号中的内容外,其他都是
    • *[] 指任何与括号内内容匹配的内容。

    在你的情况下:

    body > *:not(.toolbar)   // means any element immediately under the body tag that isn't of class .toolbar
    body > *[selected="true"]    // means any element immediately under the body tag where the selected attribute is "true"
    

    > * 在CSS 2.1规范中定义。这个 :not 伪类和 [] 选择器在CSS 3规范中定义。

    见: http://www.w3.org/TR/CSS21/selector.html http://www.w3.org/TR/css3-selectors /更多信息。

        3
  •  2
  •   user1558952    11 年前

    表示子元素

    .cont > div {
        color: #fff;
    }
    

    这将是:

    <div class="cont">
        <!-- NOTE: THIS NOTE IS TO TELL YOU WHICH IT AFFECTS 
             It only affects the below div. Not the p.
             so "jabberwocky" text would be white, but "lorem ipsum" text in the p, would be the default font color. -->
        <div>jabberwocky</div>
        <p>lorem ipsum</p>
    </div>
    
        4
  •  1
  •   Jason Plank Steve Leung    13 年前
    • > -子选择器

      即。

      div > p > b {
       font-size:100px;
      }
      

      这将选择所有 b 内部标签 p 内部标签 div 标签。

    • :not(..) -非选择器

      匹配页面上不符合NOT语句括号中条件的任何元素。即

      div:not(.toolbar)
      

      将匹配没有类工具栏的任何DIV

    • [attr='val'] -属性选择器

      这将匹配属性与指定值匹配的任何元素。示例:如果要使所有复选框变为红色。

      input[checkec='true'] {
        background-color:red;
      }
      

    你应该在CSS 2.1选择器中搜索更多信息。