I’m trying to refresh an image by first removing and then adding back its src attribute with jQuery, but, unfortunately, this causes it to collapse and shift the elements below it up and down again after I reset it, which is quite annoying. How could I avoid this behavior?
Relevant HTML:
<figure>
<figcaption>Result</figcaption>
<img title="Result" id="result" src="http://example.com/image.bmp">
</figure>
Relevant CSS:
.gallery figure {
display: inline-block;
margin: 0;
padding: 0;
}
.gallery img {
min-width: 160px;
width: 65%;
}
(the <figure> element is included in a <section> element which has class=”gallery”)
Something like this would work:
If anything looks vague/understandable I’d be glad to explain it.
Edit: another method is to wrap your image with a
divand make sure that thedivhas a fixed height/width. Let’s suppose your HTML looks like:JavaScript:
I hope that helped!