简体   繁体   English

数据URI在CSS中不起作用

[英]Data URIs not working in CSS

I have this fileReader code 我有这个fileReader代码

for (var i = 0; i < files.length; i++) {
    fileReader.onload = (function(file) {
        return function(e) {
            z = z + 40;
            // Place the image inside the dropzone
            var image = this.result;
            $('#dropped-files').append('<div style="left: ' + z + 'px; background: url(' + image + ') cover;"> </div>');

        };
    })(files[i]);
}​

Anyway, I'm trying to set the background of the appended box to the image that was just uploaded. 无论如何,我试图将附加框的背景设置为刚刚上传的图像。 The problem is it isn't working. 问题是它不起作用。 The data URI is there but I can't seem to get it to show up as the background! 数据URI在那里,但我似乎无法将其显示为背景! Even when I click on the data URI link in inspect element I can get to the image that was uploaded, but it will not show up as the background image. 即使单击检查元素中的数据URI链接,我也可以转到已上传的图像,但它不会显示为背景图像。

Any ideas why? 有什么想法吗? The data URI is exceptionally long, but begins with the basic data and is base64, if that helps. 数据URI非常长,但是以基本数据开头,并且以base64为基础(如果有帮助的话)。

Try removing cover at the end of the background value. 尝试在背景值的末尾取下cover I don't know what you're trying to do but adding it makes Chrome throw up its hands and say it isn't a valid property value. 我不知道您要尝试做什么,但是添加它会使Chrome举起手来,说这不是有效的属性值。

EDIT: Instead, make 2 declarations: 编辑:相反,使2声明:

$('#dropped-files').append('<div style="left: ' + z + 'px; background: url(' + image + '); background-size: cover;"> </div>');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM