I have the following requirements:
- I need a
divwith an image + text inside. - The
divshould keep its aspect ratio and all images inside of thedivsshould have the same height (to do this, I use: Maintain the aspect ratio of a div with CSS). - The image inside of the
divshould be stretched in order to completely fill the parentdiv.
I have two main issues:
- As you can see, the left
divis higher, because it has text inside. This collides with thepadding-bottom: 150%-approach which is used to preserve the aspect ratio of thedivswhen their size is changed. The goal, however, is that alldivshave the same size no matter if/how much text they have inside. - Moreover, I would like to change the opacity of the background image when I hover the div. However, the text-opacity should not change. I think this can only be achieved via JS. How?