Skip to content

Instantly share code, notes, and snippets.

@dziudek
Created July 29, 2013 17:52
Show Gist options
  • Save dziudek/6106185 to your computer and use it in GitHub Desktop.
Save dziudek/6106185 to your computer and use it in GitHub Desktop.
Text centered over the image
/**
* Text centered over the image
*/
figure {
border: 1px solid red;
float: left;
position: relative;
}
img {
display: block;
}
figcaption {
position: absolute;
height: 100%;
width: 100%;
top: 0;
}
figcaption div {
border: 1px solid green;
display: table;
height: 100%
}
figcaption h1 {
display: table-cell;
vertical-align: middle;
}
<figure>
<img src="http://placekitten.com/320/320" />
<figcaption>
<div>
<h1>Lorem ipsum dolor sit amet</h1>
</div>
</figcaption>
</figure>
// alert('Hello world!');
{"view":"split-vertical","fontsize":"100","seethrough":"","prefixfree":"1","page":"all"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment