I've been struggling to make this work for the last 24 hours. Initially, I got it working in Chrome using CSS tricks' block:before
method, but then realized it didn't function properly in Firefox.
I attempted the table method as an alternative, but encountered issues with achieving 100% height.
The main goal is to position a title in the middle of each masonry brick.
Edit: My objective is to center the <p>
tag in the middle of the image. The images vary in height but have a consistent width of 200px.
<div class="item">
<p><?php the_title(); ?></p>
<img src="<?php echo $url; ?>" />
</div>
Edit: I want the text to be centered on the Overlay element. The <p>
tag has a height of 1.5em and dynamic length, which should be handled with overflow auto. The overlay element sits absolutely over the img, which can vary in height but is always 200px wide.
<div class="item>
<div class="overlay" style="overflow:hidden; height:100%; width:100%; position:absolute;">
<p>the title</p>
</div>
<img src="<?php echo $url; ?>" />
</div>
Your assistance would be greatly appreciated.