0

Hy, I have all the code, but I have no clue how to add it to :after elements. It's probably easy,here's the code:

window.onload = function() {

    var imageSrc = document
                    .getElementById('bg_head')
                     .style
                      .backgroundImage
                       .replace(/url\((['"])?(.*?)\1\)/gi, '$2')
                        .split(',')[0];    

    var image = new Image();
    image.src = imageSrc;

    var width = image.width,
        height = image.height;
        asp=height / width;
        $('#bg_head').append('<style>#bg_head:before{padding-top:'asp';}</style>');
}

You probably see what I'm trying to do. Add the asp calculated value to the padding-top or bottom of a :after element. But I don't know how to fix the code. I just need to convert everything to jquery I think? Thanks

Tao Byebye
  • 53
  • 1
  • 9
  • it would be more like '' – dandavis Sep 09 '14 at 21:03
  • This question might help, although I haven't tried it myself: http://stackoverflow.com/questions/5041494/manipulating-css-pseudo-elements-using-jquery-e-g-before-and-after – Hans Sep 09 '14 at 21:52
  • Add two + operators in your last codeline like so: `$('#bg_head').append('');` – Martin Ernst Sep 14 '14 at 10:24

0 Answers0