gpt-3.5-turbo-0301· OpenAI
WildChat-4.8M (AI2)
<div id="thumb-content-9"><img…
- User
I have above html, I want to add a image preloader while the image "mainimg_9" is loading.
- Assistant
To add a preloader while the image is loading, you can add a CSS class to the parent div, and then add a CSS animation to the preloader. Here's an example:
- Add CSS class to parent div
<div id="thumb-content-9" class="image-loading"> <img onclick="f_showdetailimage('sgce/images/44_Consumer_Electronics-OCT21_1-043.jpg', 'mainimg_9',9);" data-toggle="modal" data-target="#showdetail" title="Shenzhen Chitado Technology Co. Ltd" id="mainimg_9" class="lazy coupon_img imagefadein-x" data-checker="checked_9_landing" data-original="sgce/images/44_Consumer_Electronics-OCT21_1-043.jpg?l=3373644323" style="width: 400px;" alt="scooter, hoverboard, gyroor, chitado" src="sgce/images/44_Consumer_Electronics-OCT21_1-043.jpg?l=3373644323"> </div>- Add CSS animation to preloader
.image-loading::before { content: ""; display: block; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 50px; height: 50px; border-radius: 50%; border: 5px solid #f3f3f3; border-top: 5px solid #3498db; animation: spin 1s linear infinite; } @keyframes spin { 0% { transform: translate(-50%, -50%) rotate(0deg); } 100% { transform: translate(-50%, -50%) rotate(360deg); } }