为什么我不能设置背景图片? [英] Why can't I set a background image?

查看:248
本文介绍了为什么我不能设置背景图片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这是重复的问题,但我的代码有问题。
我已经搜索了stackoverflow和w3schools为背景图像设置
,并编写了两个网站上的代码,但仍然存在以下代码的问题。

I know it's repetitious question but I have problem with my code. I have searched stackoverflow and w3schools for a background image setting and wrote the code that was on both sites exactly but still I have problem with the following code.

body {
  background-image: url("C:\Users\mehra\Desktop\Male-Fitness-Models-BAck.jpg");
}

body{  background-image: url("Male-Fitness-Models-BAck.jpg");  }

以上是我用于设置背景的代码,但都不起作用。

above are the codes I used for setting background, but neither of them work.

HTML图片

推荐答案

如果背景图像文件位置正确,则可能需要将高度和宽度添加到背景图像的容器中。 b
$ b

If the background image file location is correct you might need to add a height and width to the container of the background image.

body {
  height: 500px;
  width: 500px;
  background-image: url("C:\Users\mehra\Desktop\Male-Fitness-Models-BAck.jpg");
}

这篇关于为什么我不能设置背景图片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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