physicsboy
physicsboy

Reputation: 6326

Change CSS applied to ::before using Polymer

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

Answers (1)

Richard Parnaby-King
Richard Parnaby-King

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

Related Questions