在文本
問題之前,我有很多帶有圓圈的鏈接- 圓圈沒有完全垂直居中,文本
稍微靠下
有沒有辦法解決這個問題?
.title {
font-size:2rem;
display:inline-block;
vertical-align:middle;
}
<div class='title'>● LOREM IPSUM</div>
uj5u.com熱心網友回復:
我認為你不能用 HTML 符號做你想做的事情。為了澄清這一點,我稍微修改了您的代碼。包含兩個 div 元素的包裝器。一個是 HTML 符號,另一個是文本。為了對齊這一點,我使用了 padding-bottom。
或者,我會使用list-style-type: disc;. 或者使用自定義專案符號。
.wrapper {}
.dot {
font-size:1.5rem;
padding-bottom:20px;
vertical-align:middle;
text-align: center;
}
.txt {
font-size:2rem;
}
/* ---------------- */
.alter {
font-size:2rem;
display: list-item;
list-style-type: disc;
list-style-position: inside;
}
<div class="wrapper">
<span class="dot">●</span>
<span class="txt">LOREM IPSUM</span>
</div>
<p class="alter">LOREM IPSUM 2</p>
uj5u.com熱心網友回復:
它們看起來垂直居中對我來說,但是如果您可以更改標記,這可能會有所幫助嗎?我將您的專案符號包裹在 a 中span并添加display: flex; align-items: center;到您的標題中。還給了你.titlealine-height和span一點右邊距的間距。
.title {
font-size: 2rem;
line-height: 1;
display: flex;
align-items: center;
}
.title span {
margin-right: .5rem;
}
<div class='title'><span>●</span> LOREM IPSUM</div>
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/379692.html
