0
我有下面的代码:如何添加更多的填充字段而不影响另一个字段?
<a class="my-profile" href="link">
<div class="my-picture">[picture]</div>
<div class="my-fields">
<span class="my-name">[name]</span>
<span class="my-medal">[medal]</span>
</div>
</a>
它具有以下主题化:
.my-profile {
background-color: black;
color: white;
display: inline-block;
height: 35px;
padding-left: 5px;
padding-right: 5px;
text-decoration: none;
}
.my-picture {
display: inline-block;
padding-top: 5px;
height: 25px;
width: 25px;
}
.my-fields {
display: inline-block;
font-size: 13px;
padding-left: 5px;
padding-top: 8px;
vertical-align: top;
}
.my-medal {
padding-left: 5px;
height: 16px;
width: 16px;
}
我想一些更顶级的填充添加到奖牌场,但是当我添加padding-top: 5px
到.my-medal
类,名称字段也被移动。
为什么会发生这种情况,我该如何预防它?
我已经更新了我的问题,并在图像字段“my-picture”和“my-medal”上添加了宽度和高度。为什么'vertical-align'没有从'my-fields'类继承? – Jeroen
因为这些元素不是内联的,“垂直对齐”只影响内联内容。因为它们(大概)被设置为块,所以它们将具有它们自己的默认垂直对齐(通常是“基线”)。 –