如何显示此背景图片 [英] how to show this background image

查看:84
本文介绍了如何显示此背景图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您可以使用浏览器打开它,但是我无法在这些代码中显示背景图像.这是什么问题?

you can open it using browser, but I cannot display the background image in these code. what problem it is?

<!DOCTYPE html>
<html>

<head>
  <title></title>
</head>

<body>

  <div style="background-image:url(https://www.marsha.com.hk/libs/img/Massage-landing 1906x810_R1-03.jpg);  
           width:100%;
           background-position: center;
          background-repeat: no-repeat;
          background-size: contain;
          position: relative" class="item2" data-aos="fade-up">
  </div>
</body>

</html>

推荐答案

您需要做两件事:

  1. 用引号引起来的URL.
  2. 为div添加一些尺寸.

在下面的更新示例中,我向div添加了500x500尺寸

In the updated example below I have added a 500x500 dimension to the div

<!DOCTYPE html>
<html>

<head>
  <title></title>
</head>

<body>

  <div style="background-image:url('https://www.marsha.com.hk/libs/img/Massage-landing 1906x810_R1-03.jpg');  
           width:100%;
           background-position: center;
          background-repeat: no-repeat;
          background-size: contain;
          position: relative; width: 500px; height: 500px" class="item2" data-aos="fade-up">
  </div>
</body>

</html>

这篇关于如何显示此背景图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆