How do I override CSS set on a pseudo element?

frequent picture frequent · Jul 24, 2013 · Viewed 44.2k times · Source

I know that has been asked before, but I find no clean way of overriding this CSS:

.ui-input-search:after {
    content: "";
    height: 18px;
    left: 0.3125em;
    margin-top: -9px;
    opacity: 0.5;
    position: absolute;
    top: 50%;
    width: 18px;
}

I need to leave ui-input-search on the element, but can add my own class, like:

.ui-input-search-no-pseudo:after {
   content: "";
}

Question:
Is there an easy way to remove "pseudo-css" without having to overwrite the CSS line by line?

Thanks!

Answer

Sacha picture Sacha · Jul 24, 2013

As far as I can tell there is no other way than to override all properties. The styles are defined on the element, they won't just disappear because of another selector that targets the element.

If you only want to remove the pseudo element from the page you can do content: none.

Added from comments below:

The difference between content: "" and content: none is that content: "" produces a pseudo-element with no content (i.e. an empty pseudo-element), whereas content: none prevents the pseudo-element from being generated at all.