'&' 是什么意思选择器选择? [英] What does the '&' selector select?

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

问题描述

this codepen 中有一个 css 选择器 &:hover 该选择器匹配什么?

In this codepen there is a css selector &:hover what does that selector match?

推荐答案

我相信 & 符号是一个 Sass特征.来自文档:

I believe the ampersand is a Sass feature. From the docs:

引用父选择器:&

有时在其他情况下使用嵌套规则的父选择器很有用方式比默认.例如,您可能想要特别的选择器悬停时的样式或主体时的样式元素有一个特定的类.在这些情况下,您可以明确地使用 & 指定应插入父选择器的位置字符.

Sometimes it’s useful to use a nested rule’s parent selector in other ways than the default. For instance, you might want to have special styles for when that selector is hovered over or for when the body element has a certain class. In these cases, you can explicitly specify where the parent selector should be inserted using the & character.

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

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