根据其他 SO 解决方案,我尝试为伪元素 ( height: X px; width: X px;
)提供明确的固定尺寸,但即使这有效,我也想要一个适合其父元素的可缩放、响应式图像,因此固定尺寸对我来说是不可接受的。我怎样才能background-image
同时显示并自动缩放?
HTML:
<h3>This is a title</h3>
CSS:
h3:before{
background-image:url('https://store.ashenglowgaming.com/wp-content/uploads/2018/02/cropped-agg-store-logo-4-FULLSIZE-1.jpg');
background-size: contain;
background-repeat: no-repeat;
display: block;
}
试试这个
h3:before{
background-image: url(https://store.ashenglowgaming.com/wp-content/uploads/2018/02/cropped-agg-store-logo-4-FULLSIZE-1.jpg);
background-size: contain;
background-repeat: no-repeat;
content: '';
height: 110px;
display: block;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句