gpt4 book ai didi

html - 如何将 css 属性与不同的类一起使用?

转载 作者:行者123 更新时间:2023-11-28 10:39:04 30 4
gpt4 key购买 nike

我有基于不同 Action 的不同 css 类。一切正常,但是当我根据条件应用 activeBackground 类时,它使 div background-color 变为绿色,但是 border-left-color 是没有变成绿色它仍然使用 .arrow-div 类。如何解决此问题并在需要时应用 .activebackground 类?

HTML

<div class="text-arrow" ng-class="{'activeBackground': applyActiveFile, 'completeBackground':applyComplete}">File Selection
<span class="arrow-div"></span>
</div>

CSS

.text-arrow {
background-color:#BABABA;
color:#fff;
display:inline-block;
padding-left:45px;
}
.arrow-div {
border-style: dashed;
border-color: transparent;
border-width: 0.15em;
display: -moz-inline-box;
display: inline-block; /* Use font-size to control the size of the arrow. */
font-size: 100px;
height: 0;
line-height: 0;
position: relative;
vertical-align: middle;
width: 0;
background-color:#fff; /* change background color acc to bg color */
border-left-width: 0.2em;
border-left-style: solid;
border-left-color: #BABABA;
left:0.25em;
}
.activeBackground{
background-color: green;
border-left-color: green !important;
}

最佳答案

在我看来,您正在将 .arrow-div.activeBackground 应用于不同的元素,并且您的代码编写方式是 .activeBackground 不能覆盖 .arrow-div 因为它被应用到不同的元素(父元素)。要影响子元素(包含箭头的范围),您需要设置一个直接针对 .activeBackground 的任何子 .arrow-div 的 css 规则。

我的解决方案是像这样简单地修改您的 css,提供一种更改箭头 div 的方法:

.activeBackground{
background-color: green;
}
.activeBackground .arrow-div{
border-left-color: green;
}

这是它的一个 fiddle Action : https://jsfiddle.net/cupno5g9/

关于html - 如何将 css 属性与不同的类一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34637874/

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