I'm struggling to achieve something seemingly simple but can't quite get it to work.
My goal is to display article previews on my website in a tiled format.
For example, the tiles would have a fixed height and width, say 300px by 300px.
I'd like the article title and maybe a short excerpt to appear overlaying the image, similar to what theverge.com does.
I need help with setting up a proof of concept mockup. I can handle the specific styling myself, but I'm stuck on the structure.
I can't seem to make the h1 overlay the img properly.
I've tried putting both elements within separate div containers inside a parent container, and then positioning the container with the h1
or "post info" absolutely.
But no matter what I try, it doesn't quite work out as expected.
HTML:
<div class="container">
<div class="feat-img">
<img src="www.sample.com"/>
</div>
<div class="post-info">
<h1>Post Title</h1>
</div>
</div>
CSS:
.container: {width: 300px; height:300px;float:left;}
.feat-img img: {width:300px; height:300px; float:left;}
.post-info: {position:absolute;bottom:0px;}
Although I know there are issues with that style, I just put it together quickly. It captures the gist of what I'm thinking.
I would appreciate any assistance since I haven't been able to find what I need (probably because I'm not sure what I should be looking for).