Is there a specificity among CSS properties that affects how styles are applied?
I've been experimenting with flexbox and encountered an interesting scenario:
The second selector .flex-basis-5
is added dynamically via JavaScript based on certain conditions.
I expected the value of flex-basis to be overridden by the new selector, but it only takes effect if I use !important
.
.flex-container {
display: flex;
flex-flow: row wrap;
}
.flex-item-7 {
flex: 0 0 58.33%;
}
.flex-basis-5 {
flex-basis: 41.66%;
}
<div class="flex-container">
<div class="flex-item-7 flex-basis-5">Some content</div>
</div>
Any insights or explanations would be appreciated!