如何为.less中存在两个类的按钮创建CSS选择器?
我有这个CSS:如何为.less中存在两个类的按钮创建CSS选择器?,css,Css,我有这个CSS: button { background: @button-background; color: @text; &.focus { background-image: linear-gradient(#79d858, #569e3d); border-color: #4a993e; color: white; } }
button {
background: @button-background;
color: @text;
&.focus {
background-image: linear-gradient(#79d858, #569e3d);
border-color: #4a993e;
color: white;
}
}
当按钮具有.focus和:hover时,如何创建另一个CSS?请注意,焦点是我添加到按钮的一个类,与按钮是否有焦点无关。谢谢如评论中所述,您可以使用&:hover 钮扣{ 背景:@按钮背景; 颜色:@text; &.焦点{ 背景图像:线性梯度79D8585859E3D; 边框颜色:4a993e; 颜色:白色; &:悬停{ 颜色:红色; } }
} 如注释中所述,您可以使用&:hover 钮扣{ 背景:@按钮背景; 颜色:@text; &.焦点{ 背景图像:线性梯度79D8585859E3D; 边框颜色:4a993e; 颜色:白色; &:悬停{ 颜色:红色; } } } 注:焦点上的符号是多余的 注意:焦点上的符号和是多余的。您可以使用&.focus、&:hover。或者您可能需要&.focus:hover..您可以使用&.focus,&:hover。或者您可能需要&。焦点:悬停。。
button {
background: @button-background;
color: @text;
.focus {
background-image: linear-gradient(#79d858, #569e3d);
border-color: #4a993e;
color: white;
&:hover {
...
}
}
}