I'm developing a typography oriented WordPress theme, and I'm getting troubles with the in-line images.
I can control every element and adjust its line height, bottom margin, etc, to keep the vertical rhythm. But since images pasted through the editor can have any height, they obviously disrupt all the following content.
Is it possible using margin, padding, both or another solution, to make sure that independent of the image size it will adjust to the baseline?
I know there are some alternatives like make all images turn to a multiple of the line height, that way I can keep the rhythm. Other option would be use JavaScript, not ideal, but if there's no CSS solution, I'll have to consider it.
If you want to do this purely with CSS, then you have to know the size of each image ahead of time. For example, in this demo:
I have a 20px grid, and the image has a height of 150px, so I have wrapped the image in a container with a height of 160px. This requires extra markup:
Perhaps such markup could be generated by a WordPress plugin, which receives the image markup and the minimum height and outputs a grid-aligned
div
wrapper. (I am unfamiliar with WordPress.)The alternative would be to use JavaScript, which has been addressed in this similar question.