我希望将cursor: not-allowed应用于父元素,并且这也应该适用于子元素。
我要做什么? 我有一个带有class“card”和光标指针的父div元素和带有光标指针的子元素。现在,当父div元素具有类“card”和“disabled”时,我希望父div元素和子元素都具有cursor:not-allowed。
以下是我的html代码:
<div class="card disabled">
<a href="some">
<div class="image">
<img/>
</div>
</a>
<a href="some">
<button class="icon">
<svg />
</button>
</a>
<div class="footer">
<div class="info">
<a href="somewhere">
<h4>text</h4>
</a>
</div>
<button>
<svg/>
</button>
<div class="more">
<div class="container">
<button></button>
</div>
</div>
</div>
</div>
以下是 CSS 代码:
.card {
.icon {
cursor: pointer;
}
.image {
cursor: pointer;
}
.footer {
svg {
cursor: pointer;
}
}
}
现在我已经应用了以下样式,使得当父级 div 具有 card 和 disabled 类时,鼠标指针变为 not-allowed。
.card.disabled {
cursor: not-allowed;
}
这个不起作用,请有人帮我解决一下。谢谢。