I make an adaptive newsletter and ran into a problem.
Some posts have pictures. It is necessary to make it so that when the parent element is changed, the size of the picture itself also changes. That is the problem. It is desirable to do this without JavaScript and cross-browser (except IE6).
|
1 answer
Good question. Here you need to use percentage values. For example, the parent is #main, the descendant is a regular picture img.
Then we can work with css:
#main { width: 100%; height: 150px; } #main img { width: 40%; height: 100%; }
img will take the values of its parent, and will calculate its dimensions relative to them. In general, in such situations it is not advisable to use js, but percentage values. I may have js disabled.
|