我有一些文本可能在不同的頁面上有所不同。我需要使它垂直居中。由於文字寬度較小,所以存在一些問題。動態垂直文本垂直對齊問題
.vertical-text-block {
width: 40px;
height: 100%;
position: absolute;
top: 0;
left: 0;
float: left;
background-color: grey;
}
.vertical-text {
display: block;
position: relative;
top: 50%;
white-space: nowrap;
font-size: 10px;
text-transform: uppercase;
transform: translateY(-50%);
transform: rotate(-90deg);
}
<div class="vertical-text-block">
<span class="vertical-text">ASHWANI SHARMA</span>
</div>
它應該看起來像下面附有影像:
包括你的標記 –
@ Ron.Basco完成! –