javascript - Can't seem to horizontally center text that has been translated 270 deg? -



javascript - Can't seem to horizontally center text that has been translated 270 deg? -

so have these html tables "vertical headers". using css3 translate property rotate text. of working great, except, cannot find way correctly center text horizontally. can of course of study manually center text using padding, margin, or several other properties, works if of vertical header cells same width, not case.

i have created test case in js fiddle handy slider dynamically adjusting width of 1 of columns:

http://jsfiddle.net/c7ft8nzc/

just in case, here code sample using.

html:

<table> <tr class="header"> <td>a header</td> <td>some other header</td> <td id="v"><div class="vert">a vert. header</div></td> <td><div class="vert">another vert. header here</div></td> </tr> <tr> <td>content here</td> <td>here longer content break multiple lines</td> <td>x</td> <td>y</td> </tr> <tr> <td>more content here</td> <td>here other content</td> <td>a</td> <td>b</td> </tr> <tr> <td>one more row here</td> <td>other stuff</td> <td>a</td> <td>b</td> </tr> </table> <div> <p>adjust slider alter width of first vertical header</p> <div id="slider"></div> </div>

css:

<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.3/css/base/jquery-ui.css"> <style> table{ border-collapse: collapse; width: 400px; } td{ border: 1px solid black; padding: 4px; vertical-align:top; } .header{ height: 200px; } .header td{ vertical-align:bottom; font-weight:bold; } .vert{ height:21px; width:12px; white-space:nowrap; -webkit-transform:translate(-4px, 20px) rotate(270deg); -webkit-transform-origin:0 0; -moz-transform:translate(-4px, 20px) rotate(270deg); -moz-transform-origin:0 0; -ms-transform:translate(-4px, 20px) rotate(270deg); -ms-transform-origin:0 0; -o-transform:translate(-4px, 20px) rotate(270deg); -o-transform-origin:0 0; transform:translate(-4px, 20px) rotate(270deg); transform-origin:0 0; } #v{ width:40px; } #slider{ width:400px; } </style>

js:

<script type='text/javascript' src='http://code.jquery.com/jquery-git2.js'></script> <script type='text/javascript' src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script> <script> $(function() { var s = $( "#slider" ).slider({ min: 12, max: 100, value: 40, change: function( event, ui ) { $("#v").width(s.slider( "option", "value" ) + 'px'); }, }); }); </script>

adding

margin: 0 auto;

on .vert centers text horizontally.

see updated jsfiddle.

javascript html css3

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -