How do I rotate text in css to get following output:
hi,
Edit:
Thanks for quick suggestion. I have added my sample code in jsfidle:
http://jsfiddle.net/koolkabin/yawYM/
HTML:
<div class="mainWrapper"> <div class="rotateObj"> <div class="title active">First Text Title</div> <div class="content"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> <div class="title">First Text Title</div> <div class="content hide"> Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... Here goes my bla bla bla text and more stuffs... </div> </div> </div>
CSS:
.mainWrapper{margin:0 auto; width:960px; background:#EFEFEF;} .rotateObj{position:relative; height:400px;} .rotateObj .title{ float:left; background:gray; width:50px; height:100%; /** Rounded Border */ border-radius:5px;-moz-border-radius:5px; /** Rotation */ -webkit-transform: rotate(-90deg); -moz-transform: rotate(-90deg); transform:rotate(-90deg); filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); } .rotateObj .active{background:green;} .rotateObj .content{float:left;width:600px;height:100%;padding:20px;} .hide{display:none;}
The problem I am facing is that when we rotate the text then it breaks the alignment and positions. So what is causing that, and how can I manage them?
The spinning of text on mouse hover is known as the Spin Effect or the Rotation Effect. In this effect, each alphabet of the word is rotated along with any one of the axes (preferably Y-axis). Each word is wrapped inside in <li> tag and then using CSS:hover Selector selector we will rotate each alphabet on Y-axis.
The direction CSS property sets the direction of text, table columns, and horizontal overflow. Use rtl for languages written from right to left (like Hebrew or Arabic), and ltr for those written from left to right (like English and most other languages).
You need to use the CSS3 transform property rotate
- see here for which browsers support it and the prefix you need to use.
One example for webkit browsers is -webkit-transform: rotate(-90deg);
Edit: The question was changed substantially so I have added a demo that works in Chrome/Safari (as I only included the -webkit-
CSS prefixed rules). The problem you have is that you do not want to rotate the title div, but simply the text inside it. If you remove your rotation, the <div>
s are in the correct position and all you need to do is wrap the text in an element and rotate that instead.
There already exists a more customisable widget as part of the jQuery UI - see the accordion demo page. I am sure with some CSS cleverness you should be able to make the accordion vertical and also rotate the title text :-)
Edit 2: I had anticipated the text center problem and have already updated my demo. There is a height/width constraint though, so longer text could still break the layout.
Edit 3: It looks like the horizontal version was part of the original plan but I cannot see any way of configuring it on the demo page. I was incorrect… the new accordion is part of the upcoming jQuery UI 1.9! So you could try the development builds if you want the new functionality.
Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With