html - (HTML CSS) 代码示例 div 弄乱了我的页面
问题描述
我创建了一个 div 示例,它使用 /google/code-prettify 库,这是一个颜色库。它基本上是另一个带有文本区域的 div 内的 div。每当我尝试在下一行中添加新段落、标题或其他示例时,它都会弄乱页面。关于 prettyprint lang 类的一些事情使得无法添加更多信息。
你能看到我错过了什么吗?
HTML
<div class="examplebox">
<h3>Code Example:</h3>
<div class="exampleinsidebox">
<pre style="padding-left:20px;" class="prettyprint lang-python" >
<!-- !!!!! Start of showing Code !!!!!-->
# I am a comment
print("Free code wiki")
<!-- !!!!! End of showing Code !!!!!-->
</pre>
</div>
</div>
<button
onclick="window.location.href = '/TryYourselfCodes/pythonguide4.html'; "
style="left:30px;"
class="buttontest"
>
Try yourself >>
</button>
</div>
CSS
.examplebox {
background-color: #f3f4fa;
border-style: unset;
padding: 30px;
}
.examplebox h3 {
padding-bottom: 10px;
}
.examplebox button {
top: 20px;
}
.exampleinsidebox {
background-color: black;
border-style: unset;
}
.exampleinsidebox p {
font-family: "Roboto", sans-serif;
font-size: 20px;
color: white;
}
pre.prettyprint {
padding: unset;
border:none;
}
/*! Color themes for Google Code Prettify | MIT License | github.com/jmblog/color-themes-for-google-code-prettify */
.prettyprint {
background: #343434;
font-family: Menlo, "Bitstream Vera Sans Mono", "DejaVu Sans Mono", Monaco,
Consolas, monospace;
border: 0 !important;
}
解决方案
正如我所看到的,您在第二个结束 div 标记中关闭<div class="examplebox">
了该div,并且在最后一个结束标记处</pre></div></div>
没有打开- 。也许这会导致问题。<div>
</div>
推荐阅读
- c# - 为什么我的按钮在 MouseOver 上没有改变颜色?
- testing - msal npm 构建运行因加载程序问题而失败
- c# - 准备需要命令有一个事务
- javascript - Discord.js / Node.js - await 仅在异步函数中有效
- python - Python Tkinter 在一个函数中打开多个窗口
- postgresql - Postgres 访问数据库中的所有内容
- react-native - react-native run-android中的错误
- split - GoogleMaps(或任何)方向 API:将路线分成每 100 公里
- macos - minikube 错误试图在 osx 上达到 172.17.0.4:8080
- javascript - 你将如何将此 for 循环转换为 foreach?这是我正在练习模板字符串的代码