4

I'm trying to set the background of a using the data uri format, but it's not working. Is it supported?

<div id="img_div" style="background-image: url(data:image/gif;base64,R0goKG41........sadasd==);"></div>

Here is my fiddle: http://jsfiddle.net/NA9Ye/

I edited the data here so my post wouldn't be huge.

THank you

Cornwell
  • 3,304
  • 7
  • 51
  • 84
  • possible duplicate of [Is embedding background image data into CSS as Base64 good or bad practice?](http://stackoverflow.com/questions/1124149/is-embedding-background-image-data-into-css-as-base64-good-or-bad-practice) – bzlm Aug 08 '13 at 10:48
  • 3
    How is it a duplicate? I'm asking if it is possible to set a div background with it, not if it's a good idea or not to do it... – Cornwell Aug 08 '13 at 10:52

2 Answers2

2
http://jsfiddle.net/NA9Ye/5/

You have to add width and height to div with backgroun-image

    #img_div{width:1000px;
height:1000px}
Farhad
  • 742
  • 6
  • 22
1

Try putting some content in the div. Or set a height and width to it.

http://jsfiddle.net/NA9Ye/10/

<div id="img_div" style="height: 500px; width: 500px; background-image: url(data:image/gif;base64,R0goKG41........sadasd==);"></div>
Raoul George
  • 2,807
  • 1
  • 21
  • 25