0

I have a division to which I have added an image with the content attribute of a :before pseudo:

#headerBox:before{
    position:absolute;
    content:url(images/shadow2.svg);
}

Is possible with jQuery to access and set that image's width? I want to scale the image to the window's innerWidth.

I have tried to use the background-image attribute - that, I can scale - but the pseudo-selector doesn't seem to take that attribute, the image doesn't show.

Michel
  • 45
  • 8
  • possible duplicate of [Change the background-position of :before CSS selector with JQuery](http://stackoverflow.com/questions/12843982/change-the-background-position-of-before-css-selector-with-jquery) – Ram Jun 02 '13 at 16:09
  • Eeeeh, the only way I see would be to somehow list all DOM elements and see if it's in the list. Also, if you give it no content, of course no background image will show up, because its width and height will be zero. I don't know if it does take the attribute, but what's sure is that you'll never see a background image without any content, height or weight. Honestly you'd probably be luckier with prepending the image with JS/Jquery and then selecting it. – Ariane Jun 02 '13 at 16:09
  • @Ariane - I tried with text content, height and width, to no avail. – Michel Jun 02 '13 at 17:45
  • 1
    Looks like you will have little choice but to add your element in your HTML or prepend it with Jquery, then. :before stuff isn't exactly malleable. – Ariane Jun 03 '13 at 04:42

0 Answers0