html - 由于其他元素,背景图像显示中断
问题描述
我的背景被列表和 打断了,h3
但它必须是一条实线。黄色的东西是背景图像。请求帮助。用于学校项目。
在图像中,您会看到一个黄色三角形表示中断的图像:
这是我的代码:
* {
background-image: url("https://placehold.it/300x300/");
background-repeat: no-repeat;
background-color: #252525;
color: white;
font-family: arial;
}
h1 {
text-align: center;
font-size: 42pt;
background-image: url("https://placehold.it/300x300/f00/fff");
text-transform: uppercase;
}
h3 {
text-align: center;
font-size: 28pt;
text-transform: uppercase;
}
li {
list-style-type: none;
margin-top: 20px;
margin-bottom: 20px;
}
a {
color: yellow;
list-style-type: none;
width: 120px;
text-align: center;
font-size: 18pt;
box-shadow: 3px 3px 3px black;
font-weight: bold;
}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="Jonas Ploberger">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Übersicht jonas Ploberger</title>
<link rel="stylesheet" href="startseite.css">
</head>
<body>
<h1>PlobergerJonas</h1>
<h3>Home</h3>
<ul>
<li><a href="startseite.html">Home</a></li>
<li><a href="photoshop.html">PS Bilder</a></li>
<li><a href="ausbildung.html">Ausbildung</a></li>
<li><a href="kontakt.html">Kontakt</a></li>
</ul>
</body>
</html>
解决方案
这里:
* {
background-image: url("https://placehold.it/300x300/");
background-repeat: no-repeat;
background-color: #252525;
color: white;
font-family: arial;
}
您正在使用通用选择器“*”,因此您正在为 html 文档中的每个元素设置背景图像。
因此,您想将该选择器替换为“body”或您希望在其上显示该背景图像的任何其他元素。
推荐阅读
- python - 如何在几个 Numpy 数组的特定索引处查找和提取值?
- pandas - 如何在熊猫数据框中用今天的日期填充空数据?
- captcha - 简单的验证码解决
- git - linguist-vendored 和 linguist-language 在 .gitattributes 文件中不起作用
- sql - 使用选择查询的结果作为交叉表中的列定义列表
- javascript - 滚动到该部分时如何使我的导航栏链接处于活动状态?
- java - 无法从 SimpleIntegerProperty 转换为 Property
- php - 会话未在 PHP 7.4 中开始,但相同的代码在 PHP 7.1 中有效
- c++ - 为什么我的程序没有做适当的对角线差(C++)?
- php - 如何使用 PayPal 智能按钮在商品缺货时显示已售罄消息