Skip to content

Instantly share code, notes, and snippets.

@oksushi
Created February 18, 2014 03:24
Show Gist options
  • Save oksushi/9064144 to your computer and use it in GitHub Desktop.
Save oksushi/9064144 to your computer and use it in GitHub Desktop.
Using table display to vertically centre a list of blocks
/**
* Using table display to vertically centre a list of blocks
*/
ul {
list-style: none;
margin: 0;
padding: 0;
text-align: justify;
}
li {
text-align: center;
display: inline-table;
width: 200px;
background: #eee;
vertical-align: top;
height: 100px;
}
a {
display: table-cell;
vertical-align: middle;
transition: .5s background;
}
a:hover {
background: hotpink;
}
<!-- content to be placed inside <body>…</body> -->
<ul>
<li><a href="/">Text</a></li>
<li><a href="/">Longer Text onto two lines, Longer Text onto two lines</a></li>
<li><a href="/">Text</a></li>
<li><a href="/">Longer Text onto two lines, Longer Text onto two lines</a></li>
</ul>
// alert('Hello world!');
{"view":"split","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