为什么背景图片不加载我的css文件

u5rb5r59  于 2023-07-01  发布在  其他
关注(0)|答案(2)|浏览(148)

我试图加载背景图像,所以我使用的CSS背景图像的URL,但它不工作,这意味着它是不加载。

.home {
  display: flex;
  align-items: center;
  min-height: 100vh;
  background-image: url(../wordpress/img/online-training.jpg);
  background-size: cover;
  background-position: center;
}
<section class="home" id="home">
  <div class="content">
    <span>Take The Right Step <br>For Your Business</span>
    
    <p>Tax associate is a leading consultancy firm that provides simple, effective company registration and accounting solutions to enterprises in ireland</p>
    
    <a href="#" class="btn">Get Started</a>
  </div>
</section>
vhipe2zx

vhipe2zx1#

URL可能不正确。尝试使用完整的URL,看看它是否加载例如。https://website.com/wordpress/img/online-training.jpg。如果这样做有效,那么您使用的相对URL语法可能需要调整,例如:/wordpress/img/online-training.jpg
它将工作没有报价,但它的更好地有他们在下面的建议。

00jrzges

00jrzges2#

您的css在background-image的URL中缺少双引号:

CSS:

background-image: url("../wordpress/img/online-training.jpg");
此外,您应该检查文件的路径。

相关问题