问题
I have encountered a strange bug using my OpenCart website in Chrome. The product images are not showing up but I see the white area where they should come.
If a product doesn't have an image it's aligned to the left but in this case I can see the white area where the picture normally is.
And here's the crazy part, if I click on inspect element, suddenly the image appears.
Some css code
.product-list .image {
float: left;
margin-right: 10px;
overflow: auto;
}
回答1:
In the CSS you need to set the width and height attributes.
回答2:
That is weird. Regardless, things to check:
- Z-index: The outer box that surrounds the image might be "above" the image itself. Add
z-index
to the image with a value of 9999 to check - Position: if it's parent container or god knows what else has a weird position it could be affecting where the child element, in this case an image is appearing.
- Disable JS - Javascript might be causing an issue here, try disabling it to check.
- Also, when you use chrome dev tools, you are technically "hovering" on the image. And you say it suddenly appears. So I'd take a look at your :hover rules as they apply to images. A lot of sites will use a sprite technique that shows one image in normal state, and then shift the background to a different part of the same image on hover. Your normal state could be empty and the hover then moves the bkgd position to the image you want.
Let me know how this turns out.
回答3:
More scenarios to replicate this issue 1. Close inspect if not already opened. 2. Resize inspect if already opened. 3. Resize browser window.
来源:https://stackoverflow.com/questions/19956546/images-not-showing-in-chrome-until-i-click-inspect-element