[英]Change background-image css resulting adding additional div
I'm creating a template in blade.php based on an original HTML template. 我正在基于原始HTML模板在blade.php中创建一个模板。 When I try to change the URL of the background image, instead of changing it, it creates an additional div to the style, like this , which results in other templated background attributes such as
position
or size
being ignored. 当我尝试更改背景图像的URL而不是更改它时,它会为样式创建一个额外的div,例如this ,这将导致其他模板化背景属性(例如
position
或size
被忽略。 How can I solve this? 我该如何解决?
<div data-bs-parallax-bg="true" id="pic_promo_1" style="background-image: url(#); height: 500px; background-position: center; background-size: cover;"></div>
if ($('#pic_promo_1').length) {
$('#pic_promo_1').css('background-image', 'url({{asset("/images/products/$products->pic_promo_1")}})')
}
Write like this 这样写
if ($('#pic_promo_1').length) {
var imageUrl = "/examples/images/sky.jpg";
$("#pic_promo_1").css("background-image", "url(" + imageUrl + ")");
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.