什么是css“[class * = my-class] .my-subclass”做什么? [英] What is css "[class*=my-class] .my-subclass" doing?

查看:210
本文介绍了什么是css“[class * = my-class] .my-subclass”做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我继承了一些css,我已经在网上搜索,以了解什么是由一块css表示,看起来像:

I inherited some css and I have searched everywhere online to understand what is being expressed by a block of css that looks like:

 [class*=wrapper] .logo {
                padding-top: 32px !important;
            }

星号和方括号是什么?

What is the asterisk and square brackets doing?

很难在google上搜索[和* ...如果问题是dumb,很抱歉。

It is hard to search for [ and * on google... Sorry if the question is dumb.

推荐答案

它选择具有类 logo 的元素,该元素的祖先具有 wrapper 在其类属性中的某处。例如,注意类 burgerwrapper 也会导致下面选择的元素。

It selects an element with class logo that has an ancestor that has wrapper somewhere in its class attribute. For example note that the class burgerwrapper also leads to the element being selected below.

[class*=wrapper] .logo {
  color: #f99;
}

<div class="logo">Not selected</div>

<div class="wrapper">
  <div class="logo">
    Selected
  </div>
</div>

<div class="burgerwrapper">
  <div class="logo">
    Selected
  </div>
</div>

a href =http://css-tricks.com/attribute-selectors/> http://css-tricks.com/attribute-selectors/ 了解属性选择器的一些背景信息。

See http://css-tricks.com/attribute-selectors/ for some background information on attribute selectors.

这篇关于什么是css“[class * = my-class] .my-subclass”做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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