Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在CSS类中插入CSS类_Css - Fatal编程技术网

在CSS类中插入CSS类

在CSS类中插入CSS类,css,Css,我想要的是这样的代码: class1:悬停{ 背景色:#f9f9f9; 盒影:1px 1px 8px#E0DADF; 类别2{ 不透明度:0.5; } } 这是可能的还是有其他方法可以做到这一点?您需要使用或。您需要使用或。.class1:悬停{ 背景色:#f9f9f9; 盒影:1px 1px 8px#E0DADF; } .class1:悬停.class2{ 不透明度:0.5; } 或使用。。类别1:悬停{ 背景色:#f9f9f9; 盒影:1px 1px 8px#E0DADF; } .cla

我想要的是这样的代码:

class1:悬停{
背景色:#f9f9f9;
盒影:1px 1px 8px#E0DADF;
类别2{
不透明度:0.5;
}
}
这是可能的还是有其他方法可以做到这一点?

您需要使用或。

您需要使用或。

.class1:悬停{
背景色:#f9f9f9;
盒影:1px 1px 8px#E0DADF;
}
.class1:悬停.class2{
不透明度:0.5;
}
或使用。

。类别1:悬停{
背景色:#f9f9f9;
盒影:1px 1px 8px#E0DADF;
}
.class1:悬停.class2{
不透明度:0.5;
}
或者使用。

以防,或者,是的,这是可能的。但是,如果要嵌套CSS类,可以这样做:

class1:hover{
    background-color:#f9f9f9;
    box-shadow: 1px 1px 8px #E0DADF;
}

class1:hover class2{
    opacity:0.5;
}
以防,或者,是的,这是可能的。但是,如果要嵌套CSS类,可以这样做:

class1:hover{
    background-color:#f9f9f9;
    box-shadow: 1px 1px 8px #E0DADF;
}

class1:hover class2{
    opacity:0.5;
}
只是想补充一点。 您还可以做的是使元素具有多个类。比如说,

<div class="class1 class2"></div>
<div class="class2"></div>

第一个
div
元素也将具有第二个元素的css样式。

只是为了添加一些东西。 您还可以做的是使元素具有多个类。比如说,

<div class="class1 class2"></div>
<div class="class2"></div>


第一个
div
元素也将具有第二个元素的css样式。

您希望通过嵌套实现什么?不,普通CSS不能这样做。当我使用class1时,class2也会改变。@KevinSteveManingo-是否
class2
位于DOM中的
class1
中?您希望通过嵌套实现什么?不,普通CSS不能这样做。当我使用class1时,class2也会改变。@KevinSteveManingo-是否
class2
位于DOM中的
class1
中?