javascript - 准确设置文本位置
问题描述
.noten_stats {
height: 200px;
background: #cc2b5e;
background: -webkit-linear-gradient(to right, #753a88, #cc2b5e);
background: linear-gradient(to right, #753a88, #cc2b5e);
border-radius: 5px;
box-shadow: 1px 1px 5px #ddd;
}
.noten_stats_title {
color: #ffffff;
height: 20%;
padding: 20px;
font-family: Montserrat-Medium;
}
.punkte_container {
height: 80%;
margin: auto;
width: 50%;
display: flex;
justify-content: center;
}
.punkte {
color: #ffffff;
font-size: 50px;
font-family: Montserrat-Bold;
}
.punkte_text {
color: #ffffff;
font-family: Montserrat-Medium;
}
<div class='noten_stats'>
<p class="noten_stats_title">Deine Durchschnittsnote</p>
<div class="punkte_container">
<p class="punkte">15</p>
<p class="punkte_text">Punkte</p>
</div>
</div>
所以现在我希望“Punkte”与 15 的高度相同。这样文本“Punkte”就在“15” 的底部对齐。
我尝试了很多,但没有任何效果。
解决方案
.noten_stats {
height: 200px;
background: #cc2b5e;
background: -webkit-linear-gradient(to right, #753a88, #cc2b5e);
background: linear-gradient(to right, #753a88, #cc2b5e);
border-radius: 5px;
box-shadow: 1px 1px 5px #ddd;
}
.noten_stats_title {
color: #ffffff;
height: 20%;
padding: 20px;
font-family: Montserrat-Medium;
}
.punkte_container {
margin: auto;
width: 50%;
display: flex;
justify-content: center;
align-items: baseline;
}
.punkte {
color: #ffffff;
font-size: 50px;
font-family: Montserrat-Bold;
}
.punkte_text {
color: #ffffff;
font-family: Montserrat-Medium;
}
<div class='noten_stats'>
<p class="noten_stats_title">Deine Durchschnittsnote</p>
<div class="punkte_container">
<span class="punkte">15</span>
<span class="punkte_text">Punkte</span>
</div>
</div>
使用span
而不是p
. 它显示内联。
推荐阅读
- python - 在 Python 上使用 if 语句和追加的问题
- html - html css tooltips on hover event 我可以制作特定的宽度吗?
- python - Python比较两个列表的变化
- javascript - 对于在 python 到 javascript 语言中
- vhdl - 接收 VHDL 代码错误:使用 GHDL 的对象子类型不是本地静态的
- java - 最小重量的背包
- javascript - Z-index 阻止了 gif 动画的运行 | jQuery CSS HTML JS
- python - tkinter 实时数据标签更改(取决于用户输入)
- anychart - 在股票图表中用两根手指禁用日期范围向左/向右滑动操作
- discord.js - 我已经被这个错误困扰了大约 2 周,我仍然没有设法修复它