'>' 和有什么区别和 CSS 选择器中的空格? [英] What is the difference between '>' and a space in CSS selectors?

查看:12
本文介绍了'>' 和有什么区别和 CSS 选择器中的空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用这种语法有什么意义

What's the point using this syntax

div.card > div.name

这有什么区别

div.card div.name

推荐答案

A >B 只会选择 B 是 A 的直接子元素(也就是说,中间没有其他元素).

A > B will only select B that are direct children to A (that is, there are no other elements inbetween).

A B 将选择 A 内的任何 B,即使它们之间还有其他元素.

A B will select any B that are inside A, even if there are other elements between them.

这篇关于'>' 和有什么区别和 CSS 选择器中的空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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