I'm working on a design where I need to display text information over an image. The challenge is aligning the text properly, especially when the screen size changes due to using a grid system (1140). Currently, I have a div with transparent background and formatted content placed below the image. By using margin-top: -50%
in CSS, I can position the text over the image, but it doesn't always line up correctly as the screen size shifts.
This is what my code looks like so far:
HTML (in Slim)
.fourcol
.book
img src="#{book.image_url}"
.book-info
header
h4.title
= book.title
h6.author
= book.author
p.description
= book.description
Relevant CSS:
.book-info {
margin-top: -62%;
padding: 1em;
padding-bottom: 1.5em;
float: left;
background-color: black;
opacity: .8; }
My question is, how can I make sure that the bottom of `book-info` always aligns with the bottom of the image?