为什么我不能显示背景图像?

时间:2019-07-25 09:48:17

标签: html css

我猜我的CSS有问题,但是我找不到它们。如何将该图像显示为背景?

// The closure is executed later on, thus it should outlive the function lifescope.

let param = 10
 self.onClosureFromParent(param)

我无法显示图片

3 个答案:

答案 0 :(得分:4)

URL中不能包含文字空间。您的url()无效,因此CSS解析器将其删除。

将空格编码为%20

    <div style="
        background-image: url(https://www.marsha.com.hk/libs/img/Massage-landing%201906x810_R1-02.jpg);  
        width:100%;
            height:100vh;
        background-position: center;
        background-repeat: no-repeat;
        background-size: cover;
        "></div>

答案 1 :(得分:2)

尝试用%20更改网址上的空格,如下所示: https://www.marsha.com.hk/libs/img/Massage-landing%201906x810_R1-02.jpg

答案 2 :(得分:0)

您需要在图像网址周围添加',以便

background-image: url(https://www.marsha.com.hk/libs/img/Massage-landing 1906x810_R1-02.jpg);

应该是

background-image: url('https://www.marsha.com.hk/libs/img/Massage-landing 1906x810_R1-02.jpg');

演示在https://jsbin.com/ragibad/edit?output