无论位置如何,都选择嵌套元素

时间:2017-08-16 01:44:42

标签: html css3

我想在 .demo-container 的所有子标签中选择 .demo-img 样式的所有项目。在我的应用程序中,我不知道 .demo-container 的结构。

.demo-container > .demo-img {
    width: 100%;
    height: 100%;
    transition: width height 400ms ease-out;
}

.demo-container:hover > .demo-img {
    width: 102%;
    height: 102%;
}

<div class="demo-container">
    <div>
        <img class="demo-img" />
    </div>
    <div>
        <div>
            <img class="demo-img" />
        </div>
    </div>
</div>

2 个答案:

答案 0 :(得分:0)

.demo-container{
  width: 500px;
  height: 500px;
  background-color: green;
}
.demo-container .demo-img {
    width: 100px;
    height: 100px;
    transition: width height 400ms ease-out;
    background-color: red;
}

.demo-container:hover .demo-img {
    width: 200px;
    height: 200px;
}
<div class="demo-container">
    <div>
        <img class="demo-img" />
    </div>
    <div>
        <div>
            <img class="demo-img" />
        </div>
    </div>
</div>

只需使用课程

答案 1 :(得分:0)

除了Young Kyun Jin的回答,你也可以选择没有上课:

 <dependentAssembly>
    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />   </dependentAssembly>