[英]Align text on the side and top of other text css
label{ font-size:20px; } label sup{ font-size: 12px; vertical-align: top }
<label><sup>R$</sup>54.133<sup>73</sup></label>
使用上標標簽
<label><sup>R$</sup>54.133<sup>73</sup></label>
$ 234 07-04
<p style="font-size: 30px; font-weight: lighter; color: rgba(57, 152, 27, 0.97);"><sup style="font-size: 15px;">$</sup>234<sup style="font-size: 15px;">07-04</sup></p>
請使用下面的樣式,不要混用html和樣式,那太糟糕了
.normal{ font-size: 30px; font-weight: normal; color: rgba(57, 152, 27, 0.97); } .upper{ font-weight: lighter; font-size: 15px; }
<p class="normal"> <sup class="upper">$</sup>234<sup class="upper">07-04</sup> </p>
這是實現上標的 css解決方案,請嘗試以下操作:
<label style="position:relative; top:-0.5em; margin-left: 20px; font-family: 'Segoe UI Light'; font-size:18px"">R$</label> <label style="margin-left:45px; font-size: 35px; font-family: 'Segoe UI Light'" runat="server" id="lblBalancePeriod">54.133</label> <label style="position:relative; top:-0.8em;">48</label>
HTML:
<span class="currency">
<span class="prefix">R$</span>
54.133
<span class="suffix">73</span>
</span>
CSS:
.currency {
color: green;
font-size: 40px;
line-height: 40px;
}
.prefix, .suffix {
font-size: 20px;
vertical-align: text-top;
}
在Plunker中顯示。
您可以使用flexbox:
<div class="container">
<label class="sign">R$</label>
<label class="number">54.133</label>
<label class="decimal";>48</label>
</div>
<style>
.container{
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
}
label.sign{
align-self: flex-start;
font-size: 20px;
}
label.number{
font-size: 30px;
}
label.decimal{
align-self: flex-start;
font-size: 20px;
}
</style>
這里更多
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.