首页 > 解决方案 > 图像未在 css 中加载

问题描述

我在 bootstrap/css 中有问题。我想从源文件夹加载图像,并在 css 中输入以下代码:

background: url('../img/home.jpg') no-repeat;

但它没有显示在页面上的我的主页部分。

https://codepen.io/write/image-not-loading

标签: htmlcssbootstrap-4

解决方案


也许尝试

    background-size: cover;

或者正如 ZohirSalak CeNa 所说,调整包含背景图像的元素的大小,除非它是你的身体。

HTML

<html>
    <head>
        <title>Your Title</title>
    </head>
    <body class="your-class">

    </body>
</html

CSS

.your-class {

    background-image: url('../img/home.jpg') no-repeat;
    background-size: cover;

}

另外,请确保您有正确的图像路径


推荐阅读