2

Possible Duplicate:
css vertical centering

I'm trying to get text centered in a vertical tab on the side of the screen. So far I have the following CSS and HTML:

CSS

body
{
    font-family: Arial;
}
.panel
{
    position:absolute;
    top: 0px;
    bottom: 0px;
    left: -300px;
    width: 299px;
    border-right: 1px solid black;
}

.tab
{
    position: absolute;
    top: 10px;
    width: 16px;
    right: -16px;
    height: 75px;
    border-top: 1px solid black;
    border-bottom: 1px solid black;
    border-right: 1px solid black;
    cursor: default;
}

.tab div 
{
    position: relative;
    display: block;
    left: 1px;
    width: 75px;
    height: 15px;
    font-size: 14px;
    font-weight:normal;
    line-height: 15px;
    text-align: center;
    -moz-transform:rotate(-270deg); 
    -moz-transform-origin: bottom left;
    -webkit-transform: rotate(-270deg);
    -webkit-transform-origin: bottom left;
    -o-transform: rotate(-270deg);
    -o-transform-origin:  bottom left;
    filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=1);
}

HTML

<div class="panel">
    <div id="pnlStack" class="tab"><div>Name</div></div>
</div>

Everything look great in IE8 but in all other browsers I've tried (FF, Opera, Chrome) the text is not centered in the tab. how can I fix this so it works correctly?

Community
  • 1
  • 1
Justin808
  • 20,859
  • 46
  • 160
  • 265
  • You cannot compare IE's non-standard transform to the modern browsers proper use of the standard transform. Obviously the modern browsers are doing the same thing and handling the code as it was written. – Rob Dec 03 '11 at 01:44
  • @Rob -I wan't comparing anything :) IE's transform is useless 90% of the time. In this instance it works as needed to produce an effect. – Justin808 Dec 03 '11 at 01:48
  • 1
    @casperOne - This is NOT an exact duplicate. the other question asked how to do it, I asked how to fix and issue with it. THe other answer was to use tables, this answer fixed the problem with CSS. Sheesh, helps to read before you close. Also removing the comment that was here linking to that question and saying it wasn't a duplicate was dumb. – Justin808 Dec 04 '11 at 21:45

2 Answers2

2

You need to make sure the left bottom of the word div is lined up with the top left of the panel. See http://jsfiddle.net/8gU8z/4/ I added a top: -15px equal to height of your div.

To target IE and "reverse" this, use conditional commented css like http://jsfiddle.net/8gU8z/9/, though probably in your IE style sheet (if you have one).

ScottS
  • 71,703
  • 13
  • 126
  • 146
-1

Its hard to understand whether you are talking about rotation or
L
i
k
e
This ??

Anyhow.. since you got IE to work and if talking about rotation you can add this
to your css to make it rotate 90 deg

p.sometext {
    writing-mode:tb-rl;
    -webkit-transform:rotate(90deg);
    -moz-transform:rotate(90deg);
    -o-transform: rotate(90deg);
    white-space:nowrap;
    display:block;
}

Also.. here are some great resources about this subject:

Hope this helps :)

Sagive
  • 1,699
  • 1
  • 24
  • 34