For some reason, I really beat myself up with this ... Without a doubt, due to the lack of support for the real "right" way to center everything vertically.
Purpose:
You must have a set of four images, each of which is inside its own columns. Each image has a white overlay, which when hovering displays more of the image, as well as a caption for each of the four images, which are located horizontally and vertically inside the image.
I could easily achieve this if I set a specific width / height and pin the image inside CSS, not HTML. For SEO reasons, I want the image to be present in HTML.
In addition, due to the responsive nature of the image should be scaled to 100% of the width of the column in which they are located. Therefore, since the width scales are also scaled in height.
So, the first problem is getting a "caption" as I call it in my classes to display on top of the image. Easily accomplished with a simple position: absolute; , as well as top: 0; and left: 0; in the header and position: relative; in the container.
The big problem, and the second problem, vertically centers the text "Gallery 1" on top of the image. I have to use the bit position: absolute; , as I mentioned above, to get text on top of the image. From there, I will not be able to get the solution display: table; for work, as well as no more than -50% marginal solution for work.
Here is JS Fiddle
My HTML:
<div class="container"> <img src="http://lorempixel.com/output/city-qc-640-480-8.jpg" /> <div class="caption"> <a href="#">Gallery 1</a> </div> </div>
Any ideas on how to achieve this? I would like to support at least IE8 support, and I'm already using selectivizr, so the pseudo-classes don't bother me.
html css vertical-alignment css3 responsive-design
Michael
source share