我目前有這個:
我想將圖標 div 放在文字末尾,但因為它是一個“塊”,所以我無法使其工作。
想要的輸出:
程式碼片段:
#
* { font-family: Arial, 'sans-serif' } .test { display: flex; } .info { font-family: 'monospace'; background: black; width: 18px; height: 18px; aspect-ratio: 1; text-align: center; border-radius: 50%; color: white; }
<div class="test"> Donec rutrum congue leo eget malesuada. Donec sollicitudin molestie malesuada. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. <div class="info">i</div> </div>
P粉7386761862024-04-05 20:34:40
display: flex
(.test
).info
)設為 inline-block
並使用 display: inline-block
* { font-family: Arial, 'sans-serif' } .info { display: inline-block; font-family: 'monospace'; background: black; width: 18px; height: 18px; aspect-ratio: 1; text-align: center; border-radius: 50%; color: white; }
Donec rutrum congue leo eget malesuada. Donec sollicitudin molestie malesuada. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit.i