我在網站上有很多文本,有時我需要在文本中添加 SVG 圖示:p、h1、span、ul 和其他基于文本的組件。我如何在沒有FLEX 的情況下通過此標簽中的文本設定 SVG 高度?我嘗試行高,高度:100%,沒有幫助...
<h1>Hello <svg class="heightByFontSize"></svg> world!</h1>
<p>Hello <svg class="heightByFontSize"></svg> world!</p>
<span>Hello <svg class="heightByFontSize"></svg> world!</span>
.heightByFontSize{
// ????
}
uj5u.com熱心網友回復:
.heightByFontSize {
height: 0.7em;
width: auto;
}
<h1>Hello <svg viewBox="0 0 30 30" class="heightByFontSize"><rect x="0" y="0" height="30" width="30" /></svg> world!</h1>
<p>Hello <svg viewBox="0 0 30 30" class="heightByFontSize"><rect x="0" y="0" height="30" width="30" /></svg> world!</p>
<span>Hello <svg viewBox="0 0 30 30" class="heightByFontSize"><rect x="0" y="0" height="30" width="30" /></svg> world!</span>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/344973.html
