通过Ajax回调多个base64背景图像
答
你可能需要这样做Ref,通过使用JQuery .css() Method:
JQuery的:
$('#divID').css("background-image",'url(data:image/gif;base64,R0lGODlhPQBE....==)');
HTML:
<div id="divID">
Your div content
</div>
更新:添加多个背景的单一HTML元素通过JQuery你可以做一些事情这样克(2个的base64例子,你可以添加更多):
$('#divID').css("background-image",'url(data:image/gif;base64,R.....AAOw==), url(data:image/gif;base64,R0lGODlhDwAPAKECAAAAzMzM..H09wdGltaXplZCBi==)');
您可以用逗号,
作为url(data:image/gif;base64..), url(data:image/gif;base64..), url(data:image/gif;base64..)
分离的base64字符串添加多个url()
。但是不要忘了写一些CSS
属性的DIV(S):
#divID {
width: 500px; // any width you like
height: 250px; // any height you like
background-position: center bottom, left top; // position you like
background-repeat: no-repeat; // it is important if you don't want to see repetition of backgrounds
}
注:请避免使用/做重复的ID为您的div,如果你真的想实现多个div然后使用然后使用
$('.divsClass')
。
感谢这就是我发现的,但我想在背景中放置多个图像(在base64中),而不仅仅是一个。我们该怎么做? – MedMatrix
@MedMatrix请检查我的更新,如果它可以帮助你,请不要忘记标记为正确:) – hmd