html - 为什么背景图像属性不起作用?
问题描述
我的index.html
文件和img
文件夹位于同一目录中,我想将背景图像 div
放在.img1
.
所以我正在做这样的事情:
索引.html
.img1 {
background-image: url("img/bg-header.jpg");
position: relative;
background-size: cover;
background-repeat: no-repeat;
background-attachment: fixed;
}
<div class="img1">
<div class="ptext">
<div class="dark-overlay">
<div class="home-inner text-center">
<h2 class="display-4 text-center">PULSES</h2>
<br>
<p> HALUTZIM 26 TEL AVIV<br><br><a href="tel:+972-50-4410600">+4410600</a></p>
<br>
<br>
<div class="arrow">
<i class="fas fa-chevron-down"></i>
</div>
</div>
</div>
</div>
</div>
这应该设置 div 的背景图像,但它不起作用?
笔记:
正如我提到的index.html
style.css
,img
文件夹位于同一目录中,我在img
文件夹中有图像。难道我做错了什么 ?
请帮忙谢谢
解决方案
尝试使用标记将图像呈现为页面中的内嵌图像,以确认路径正常。如果路径没问题,检查 div 的宽度和高度,然后使用background-postion
属性。
如果仍然无法正常工作,请发布您的 html 头。
推荐阅读
- pandas - 来自 pandas 的 Arrow ListArray 与笨拙生成的箭头数组的结构有很大不同?
- spring-boot - 重新启动由命令行启动的失败的 Spring (Boot) Batch 作业
- sql - TimeScaleDB - 时间桶查询速度慢,索引和块大小的不同变化 - 我做错了什么吗?
- android - 如何找到 Android 的 SurfaceFlinger 服务的 pid?
- python - 将图像插入 PostgresSQL
- amazon-web-services - AWS:通过 Lambda 将文件上传到 S3 存储桶不起作用(正在阅读)
- c# - 原始类型的 Blazor Radzen 下拉菜单?
- python - 如何在编辑后保存 .fits 文件而不丢失标题?
- c# - 仅跳过一年中的公共假期的 Cron 表达式
- java - 从动态 args 创建一个字符串数组和一个字符串变量