image(imageurl){
return "http://web.com/"+imageurl+".jpg";
如何在CSS背景图片中使用此网址?
这是css
<div style="width: 100%;
height: 300px;
background-image: url ('image(post.postimage)');
background-repeat: no-repeat;
background-size: cover;">
</div>
答案 0 :(得分:2)
CSS background-image
.class_name{
background-image: url("image path");
}
答案 1 :(得分:1)
定义背景图像的CSS语法是
#element {
background-image: url('path/to/file.jpg');
/* Only for demonstration: */
width = 50%;
height = 50%;
}
其中element是html文档中的object-id
<div id='element'></div>
修改强>
在您的代码中
background-image: url ('image(post.postimage)');
删除'',否则该函数未被调用,而是作为文件路径传递(到不存在的位置)。