Reputation: 6326
Is it possible to change the CSS applied to an element specified with ::before
?
For example: I am wanting to change this piece of CSS
.wrapper {
position: relative;
z-index: 0;
display: inline-block;
background: #e5e5e5;
}
.wrapper::before {
position: absolute;
z-index: 1;
top: 0;
width: calc(100% - 15px);
height: 100%;
box-shadow: inset 0 10px 10px -1px rgba(0, 0, 0, 0.6);
pointer-events: none;
content: "";
}
such that the box-shadow
is applied at a specific time via javascript in something resembling this process...
addShadow : function() {
var scroll = this.$.container.scrollTop;
if(scroll >= 2) {
this.$.wrapper.classList.add('shadow');
} else {
this.$.wrapper.classList.remove('shadow');
}
},
Feel free to edit my Fiddle and give me some feedback
Upvotes: 0
Views: 38
Reputation: 14862
As you are already toggling the .shadow
class, all you need to do is alter the css selector:
.wrapper.shadow::before {
Upvotes: 4