Css for a sensitive image is as follows:
max-width: 100%; height: auto;
This will reduce the size of the image with the size of its container without exceeding the natural width of the image. However, using width: 100%; make the image be as wide as its container, regardless of the actual size of the image.
A few other notes:
align="center" out of date. You must use css to align the content, so text-align: center; .- Using
position: static; not required since this is the default value for the position property. The only time I can think about where you should use this is if you need to override some other css. - If you are not completely positioning your div (which you are not), then
top: 0; left: 0; top: 0; left: 0; will do nothing.
Without seeing the rest of the code, I think this would be the best solution for what you are trying to execute:
<div style="text-align: center;"> <img src="myImg.png" style="max-width: 100%; height: auto;" alt="FYI, image alt text is required" /> </div>
source share