javascript - 我的文字定位是否在拉伸我的网站高度?
问题描述
我正在为我的大学项目制作一个网站,并且我正在处理一些关于我的文本课程的问题。出于某种原因,我的班级似乎有一个奇怪的高度,导致我的网页底部出现一条白色条带。
#index-section div.index-title-quote{
top: 165%;
left: 50%;
margin-bottom: -100%;
transform: translate(-50%,-50%);
position: absolute;
z-index: 1;
}
#index-section div.index-title-quote h2{
font-family: 'Bebas Neue', cursive;
color: #fff;
font-size: 20px;
padding: 20px;
opacity: 0.8;
}
#index-section div.index-title-quote h5{
font-family: 'Roboto', sans-serif;
color: #fff;
font-style: italic;
font-size: 13px;
opacity: 0.6;
}
<div id="index-section">
<div class="index-title-quote">
<center><h2>"Honour may not win power, but it wins respect. And respect earns power</h2></center>
<center><h5>- Ishida Mitsunari, legendary samurai</h5></center>
</div>
这是我的代码,感谢您花时间阅读。
解决方案
你的代码有很多错误。首先,您的第一个<div>
标签没有关闭。
<div id="index-section">
您的文字在白色背景上是白色的,因此无法看到。
color: #fff;
您的 div 文本位于距顶部 165% 的页面高度,确保根本看不到它。
top: 165%;
我附上了这些修复的片段
#index-section div.index-title-quote{
top: 10%;
left: 50%;
margin-bottom: -100%;
transform: translate(-50%,-50%);
position: absolute;
z-index: 1;
}
#index-section div.index-title-quote h2{
font-family: 'Bebas Neue', cursive;
color: black;
font-size: 20px;
padding: 20px;
opacity: 0.8;
}
#index-section div.index-title-quote h5{
font-family: 'Roboto', sans-serif;
color: black;
font-style: italic;
font-size: 13px;
opacity: 0.6;
}
<div id="index-section">
<div class="index-title-quote">
<center><h2>"Honour may not win power, but it wins respect. And respect earns power</h2></center>
<center><h5>- Ishida Mitsunari, legendary samurai</h5></center>
</div>
</div>
推荐阅读
- keyboard-shortcuts - iTerm2快捷键获取上一条命令的最后一个单词
- angular - 删除嵌入在角度的power bi中的登录选项
- java - Reg:在 Spark 执行器中并行化 RDD 分区
- spring - 弹簧柱多部分和主体
- postgresql - Hasura 在表模式中添加文本 []
- python - Pandas:基于局部最小值-最大值的数据之字形分割
- java - Jboss7.2和Java8
- c# - 可以使用 c# 在多米诺骨牌中发送具有过去日期的电子邮件吗?
- rest - 如何将 API 分类为两个不同的 swagger 文档?apiModelPropertyAccessExclusions 不起作用
- javascript - @azure/ms-rest-nodeauth 和 ms-rest-azure 之间的区别