所以标签似乎从来都不太喜欢我。它总是给我带来问题,但结果总是证明他们的解决方案是显而易见的,而我只是愚蠢。但这一次,我花了 4 小时试图找出可能出了什么问题(这正是我什至将正文内容 div 命名为“body”的原因,我知道这是不必要的,哈哈)。这是代码:
\n<!DOCTYPE html>\n<!--\xc2\xa9 Copyright LightVoid Studio-->\n<html style="font-family: Helvetica, Cursive; color:white;">\n<head>\n<meta charset="UTF-8">\n<title>LightVoid Studio</title>\n</head>\n\n<style>\n .body {\n background-color:#1A2B30;\n }\n </style>\n<!--break-->\n\n<body>\n<div class="body">\n<strong>\n<p style="position:absolute;top:100px;left:20px;font-size:40px;">Hello</p>\n<p style="position:absolute;top:140px;left:20px;">This is the official LightVoid Studio\nwebsite. If You're here for the first time, let's tell Ya what We're exactly doing. LightVoid\nStudio is a relatively fresh Indie game studio that develops various software, such as games for Your computer.</p>\n\n</div>\n</body>\n\n\n<!--break-->\n\n</html>`\nRun Code Online (Sandbox Code Playgroud)\n
这是因为 的<div class="body">高度为0。它只包含绝对定位的元素,不占用任何空间,所以它基本上是空的。
一些建议:
学习使用浏览器的调试器(DOM Inspector)。它将向您显示有关元素的信息,例如它们的大小和应用的样式。
避免绝对定位。它基本上破坏了 CSS 的工作方式,这给初学者带来了困难。
编辑:还有一件事:你有一个<strong>没有结束标签的开始标签</strong>。请记住,您不能将块元素(例如<p>)放入内联元素(例如 )内<strong>。
| 归档时间: |
|
| 查看次数: |
1217 次 |
| 最近记录: |