html - 背景图片在H1之上
问题描述
h1 位于背景图像的后面。我试过使用 z-index 和 position:absolute 和 relative 但没有任何改变。如何使背景图像永远保持背景,而不必在其上添加所有其他元素?
body {
background-image: url("https://wallpaperaccess.com/full/396538.jpg");
background-repeat: no-repeat;
background-size: cover;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="index.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hotoi Sebastian | Front-End Developer & Web Designer</title>
</head>
<body>
<div class="text">
<h1>Sebastian Hotoi</h1>
</div>
</body>
</html>
解决方案
我会避免使身体位置绝对。
如果你想要标题后面的背景应该是默认的,而不是绝对我们使用任何 z-index。确保它不是图像与文本颜色相同的情况,只是让它看起来不存在:)
推荐阅读
- c# - .Net Core 3 Razor 页面管理员/产品/Upsert.cshtml IEnumerable
错误 - python - 为什么在 Heroku 上提供静态文件而不激活 WhiteNoise?
- binary-data - 如何使用EOBI简单二进制编码
- r - R——为小鼠包中的插补模型选择预测变量子集时出错
- angular - 使用从反应形式插入数据库的信息创建 PDF
- python - PyQt5中QTableWidget单元格中QWidget中的QLineEdit垂直居中?
- android - android企业中的应用内计费库
- command-line - 使用 shellexecuteW 的控制台输出
- javascript - 从输入类型文件中删除特定文件(多个)
- java - 如何隐藏导航栏而不隐藏状态栏