Displaying Images with Content URL in Firefox
An issue has been encountered where certain browsers, specifically Firefox, fail to display images when referencing them using the content property. This can be seen in the provided CSS class:
.googlePic { content: url('../../img/googlePlusIcon.PNG'); margin-top: -6.5%; padding-right: 53px; float: right; height: 19px; }
While this CSS works as expected in Google Chrome and Safari, it fails to render any image in Firefox.
Solution:
The content property can only be used with pseudo-elements such as ::before and ::after. To resolve the issue, we need to modify our CSS class as follows:
.googlePic::before { content: url('../../img/googlePlusIcon.PNG'); }
Explanation:
The content property works by inserting content before or after an element. By using ::before, we're inserting the image before the .googlePic element, which allows Firefox to display it correctly.
Further Reading:
For more information on the content property, refer to this article:
Note:
Internet Explorer 8 only supports the content property if a !DOCTYPE is specified.
부인 성명: 제공된 모든 리소스는 부분적으로 인터넷에서 가져온 것입니다. 귀하의 저작권이나 기타 권리 및 이익이 침해된 경우 자세한 이유를 설명하고 저작권 또는 권리 및 이익에 대한 증거를 제공한 후 이메일([email protected])로 보내주십시오. 최대한 빨리 처리해 드리겠습니다.
Copyright© 2022 湘ICP备2022001581号-3