I have the following requirements:
- I need a
div
with an image + text inside. - The
div
should keep its aspect ratio and all images inside of thedivs
should have the same height (to do this, I use: Maintain the aspect ratio of a div with CSS). - The image inside of the
div
should be stretched in order to completely fill the parentdiv
.
I have two main issues:
- As you can see, the left
div
is higher, because it has text inside. This collides with thepadding-bottom: 150%
-approach which is used to preserve the aspect ratio of thedivs
when their size is changed. The goal, however, is that alldivs
have 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?