Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

交集选择器和并集选择器 #15

Open
GRPdream opened this issue Apr 28, 2019 · 0 comments
Open

交集选择器和并集选择器 #15

GRPdream opened this issue Apr 28, 2019 · 0 comments

Comments

@GRPdream
Copy link
Owner

GRPdream commented Apr 28, 2019

交集选择器

如字面意思,将两个或多个选择器的值放在一起取其交集,具体使用方式为在多个选择器之间将上一个空格
试例 html 页面:

<div id="app" >
    <h1>我是'app'盒子的 h1</h1>
    <div class="mydiv">
      <h1>我是'mydiv'盒子的 h1</h1>
    </div>
  </div>

未加样式时的样子
图片

现在使用交集选择器给第二个盒子的 h1 加上样式

.mydiv h1{
      color: red;
    }

加上样式的样子
图片

可以看到,精准的为第二个 h1 加上了样式

并集选择器

继续使用上面的列子,这次为所有字体加上 font-size 属性,具体使用方式为在多个选择器之间加上一个逗号

#app,h1,.mydiv{
      font-size: 25px;
    }

效果:
图片
图片

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant