How do I remove the gray border that surrounds background images?

前端 未结 13 1937
挽巷
挽巷 2020-12-09 01:09

I\'ve come across an interesting problem in the following line of code:

  

        
13条回答
  •  -上瘾入骨i
    2020-12-09 01:46

    I had a similar issue where my initial HTML had an IMAGE tag with no source. My Javascript determined which image to show. However before the image was loaded the user saw the placeholder box.

    
    

    My fix was to update the initial image tag CSS to

    #myImage {
      display:none;
    }
    

    And then used a JQuery to show it once its content was loaded.

    $('#myImage')
    .attr('src', "/img/" + dynamicImage + '.png')
    .fadeTo(500, 1);
    

提交回复
热议问题