テキストを回転させて、div の中央に配置したいと思います。
親divで何も変更(位置、フロートなど)せず、回転したdiv(margin、top)でピクセルを手動で処理しないソリューションを試しています。それを達成する方法(ベストプラクティス)はありますか?
ブラウザの互換性は気にしません。構造を変更したり長さを修正したりせずにそれを行うための最良の方法を探しているだけです
フィドル: http://jsfiddle.net/w5K4j/29/
<div id="parent">
<div id="unknown"></div>
<div id="child">
<h3>Click this overflowing text that I'd like to V/H center when rotated</h3>
</div>
</div>
スタイルシート:
#parent {
height:300px;
width:70px;
float:left;
border: 1px solid;
}
#unknown {
float:right;
height:50px;
width:20px;
background-color: yellow
}
#child {
float:right;
height:100px;
width:70px;
clear:right;
background-color: orange;
/*text-align: center;*/
}
h3 {
/*vertical-align: middle;*/
white-space:nowrap;
border: 1px solid;
}
.rotated {
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
}