2

I have different css classes based on different actions. Everything is working good, but when I apply activeBackground class based on condition its making div background-color to green but border-left-color is not coming green its still using .arrow-div class. How can I resolve this issue and apply .activebackground class when needed?

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;
}

1 Answer 1

4

It appears to me that you're applying .arrow-div and .activeBackground to different elements, and the way your code is written, .activeBackground can't override .arrow-div because it's being applied to a different element (the parent). To affect the child element (the span containing the arrow) you need to set up a css rule that directly targets any child .arrow-div of .activeBackground.

My solution was to simply modify your css like so, providing a way to change the arrow div:

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

Here's a fiddle of it in action: https://jsfiddle.net/cupno5g9/

Sign up to request clarification or add additional context in comments.

2 Comments

This is basically div with arrow at the end so arrow is not getting the color i want to apply same color to div and arrow
Once I loaded it in a fiddle, I realized what you were doing. Give the updated answer a whirl :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.