Skip to content

Instantly share code, notes, and snippets.

@dawogfather
Created November 26, 2013 00:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dawogfather/7651718 to your computer and use it in GitHub Desktop.
Save dawogfather/7651718 to your computer and use it in GitHub Desktop.
Vertical text
/*
Vertical text
by @kizmarh
*/
.vertical-text {
display: inline-block;
overflow: hidden;
width: 1.5em;
}
.vertical-text__inner {
display: inline-block;
white-space: nowrap;
line-height: 1.5;
transform: translate(0,100%) rotate(-90deg);
transform-origin: 0 0;
}
/* This element stretches the parent to be square
by using the mechanics of vertical margins */
.vertical-text__inner:after {
content: "";
display: block;
margin: -1.5em 0 100%;
}
/* Just for more pretty example */
body {
font: 20px/1.5 Arial, sans-serif;
}
table {
margin-top: 2em;
}
th,td {
border: 1px solid;
text-align:center;
font-weight: normal;
padding: 0.5em;
}
<table>
<tr>
<th><div class="vertical-text"><div class="vertical-text__inner">First thtest</div></div></th>
<td>Some cell</td>
<td>And another</td>
</tr>
<tr>
<th><div class="vertical-text"><div class="vertical-text__inner">Second th</div></div></th>
<td>12</td>
<td>12314</td>
</tr>
<tr>
<th><div class="vertical-text"><div class="vertical-text__inner">Third th</div></div></th>
<td>12</td>
<td>12314</td>
</tr>
</table>
{"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