可以在CSS pseudo-elements(:ther/:ther/:efter)中實現圖像高度修改嗎? By assigning a class to links, such as , CSS can be utilized to display an image afterwards:
.pdflink:after { content: url('/images/pdf.png') }While this approach effectively adds an image to the link, resizing the image based on the link text becomes a challenge.在偽元素中縮放圖像的能力已經是Web開發中的一個長期問題。
調整背景圖像的傳統方法不適用於偽元素。但是,可以通過背景大小的屬性來實現對圖像調整大小的一些支持:。 pdflink:efter { 背景圖像:URL('/images/pdf.png'); 背景大小:10px 20px; 顯示:內聯塊; 寬度:10px; 身高:20px; 內容:””; }
此方法涉及調整背景大小,同時明確定義周圍塊的寬度和高度。重要的是要注意,該技術的兼容性受到限制。 MDN兼容性表提供了有關瀏覽器支持的更多詳細信息。免責聲明: 提供的所有資源部分來自互聯網,如果有侵犯您的版權或其他權益,請說明詳細緣由並提供版權或權益證明然後發到郵箱:[email protected] 我們會在第一時間內為您處理。
Copyright© 2022 湘ICP备2022001581号-3