【发布时间】:2018-06-05 23:42:46
【问题描述】:
我在 bootstrap/css 中遇到问题。我想从源文件夹加载图像,我在 css 中输入了这段代码:
background: url('../img/home.jpg') no-repeat;
但它没有显示在我的主页部分中。
【问题讨论】:
-
您的代码有效,可能您没有看到它,因为元素没有高度。
标签: html css bootstrap-4
我在 bootstrap/css 中遇到问题。我想从源文件夹加载图像,我在 css 中输入了这段代码:
background: url('../img/home.jpg') no-repeat;
但它没有显示在我的主页部分中。
【问题讨论】:
标签: html css bootstrap-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;
}
另外,请确保您的图片路径正确
【讨论】: