How to ensure CSS :hover is applied to dynamically added element

后端 未结 9 1070
广开言路
广开言路 2021-02-07 14:59

I have a script that adds full images dynamically over thumbnails when you hover over them. I\'ve also given the full images a CSS :hover style to make them expand to a larger w

9条回答
  •  误落风尘
    2021-02-07 15:46

    From this part of your question: "This works fine if the image loads quickly or is cached, but if the full image takes a long time to load and you don't move the mouse while it's loading,"

    Could it be worth while to "preload" all of the images first with JavaScript. This may allow all of the images to load successfully first, and it may be a little more user friendly for people with slower connections.

提交回复
热议问题