less - 在lesscss中继承,不继承子类

标签 less

这是我的 style.less 代码:

.transition {
    -ms-transition: all 0.3s ease-in-out;
    -moz-transition: all 0.3s ease-in-out;
    -o-transition: all 0.3s ease-in-out;
    -webkit-transition: all 0.3s ease-in-out;
    transition: all 0.3s ease-in-out;
}

.shadow {
    padding: 10px 10px 10px 10px;
    margin: 10px 10px 10px 10px;
    -moz-box-shadow: 0px 0px 10px #808080;
    -o-box-shadow: 0px 0px 10px #808080;
    -webkit-box-shadow: 0px 0px 10px #808080;
    box-shadow: 0px 0px 10px #808080;
}

    .shadow:hover {
        -moz-box-shadow: 0px 0px 10px #a5a5a5;
        -o-box-shadow: 0px 0px 10px #a5a5a5;
        -webkit-box-shadow: 0px 0px 10px #a5a5a5;
        box-shadow: 0px 0px 10px #a5a5a5;
    }


.radius {
    -moz-border-radius: 5px;
    -webkit-border-radius: 5px;
    border-radius: 5px;
}

#t1 {
    .shadow;
    .transition;
    .radius;
}

但是当我将鼠标悬停在 #t1 时,阴影不会改变。我想知道为什么它不起作用并期望添加 #t1:hover 并继承样式还有其他方法吗?

最佳答案

您需要更改 .hover 类以将 :hover 状态作为类定义的一部分:

.hover {
    ...styles...

    &:hover {
        ...hover state styles...
    }
}
.someOtherClass {
    .hover;
}

Example

关于less - 在lesscss中继承,不继承子类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12161112/

相关文章:

html - 当我将她移到顶部时,我的 div 的一部分被隐藏了

string - LESS mixin 作为函数参数

javascript - 在客户端编译 LESS?

inheritance - 更少的 Css 继承

html - CSS last-child 选择器不工作

css - LESS/CSS 功能区在调整大小时在 chrome 中中断

css - 客户端 LESS 没有使用我写的样式

css - 如何在没有 CLI 的情况下在 Angular 组件中使用更少

java - 仅对特定的一组文件使用 LessCssProcessor

css - 如何遍历 h1 - h6 标签并在每次增量时减小字体大小?