gpt4 book ai didi

html - 将类添加到父 DIV 时更改 DIV CSS 属性?

转载 作者:行者123 更新时间:2023-11-28 08:50:37 25 4
gpt4 key购买 nike

在我的网站中,我使用的是 Bootstrap 的 JavaScript 下拉模式。当下拉菜单打开时,下拉菜单和下拉按钮触发器的父 DIV 将添加“打开”类。我想要做的是将下拉按钮设置为默认的不透明度 0.8,但是当父项上有 .open 类时将其更改为 1。

我想它看起来像这样:

#menu.open > #dropdown-arrow{
opacity:1 !important;
}

但这似乎行不通。为什么不呢?

最佳答案

不要使用重写,而是使用 :not 选择器

#menu:not(.open) > #dropdown-menu {opacity:.8;}

附言不透明度有时会导致奇怪的问题。您最好使用 rgba 仅更改背景颜色和边框颜色的不透明度。

关于html - 将类添加到父 DIV 时更改 DIV CSS 属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27368549/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com