&在Sass中使用特定标签 [英] & use in Sass for specific tag

查看:163
本文介绍了&在Sass中使用特定标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用& (其指代类)与标签的组合。像这个例子:

I want to use the & (which refers to a class) in combination with a tag. Like this example:

.back {
    text-transform: uppercase;
    text-decoration: none;
    font-weight: 700;
    color: blue;

    &:hover {
        color: red;
   }
}

我只想使用a-tags 。以下是不可能的

I want only to use the hover for a-tags. The following is not possible

a&:hover {
     color: red;
}

有人知道吗?

推荐答案

如果我正确理解你的问题,你只需要不需要&

If I understand your question correctly, you just don't need the &:

.back {
  ...

  a:hover {
    color: red;
 }

}

在sass中,这将编译为 .back a:hover {color:red; } 。你不需要&,因为这是用来进一步扩展类,我不认为你想这样做。

In sass, this will compile to .back a:hover { color:red; }. You don't need the &, as this is used to further extend the back class, which I don't think you want to do.

这篇关于&在Sass中使用特定标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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