How can I draw vertical text with CSS cross-browser?
Updated this answer with recent information (from CSS Tricks). Kudos to Matt and Douglas for pointing out the filter implementation.
.rotate {
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
transform: rotate(-90deg);
/* also accepts left, right, top, bottom coordinates; not required, but a good idea for styling */
-webkit-transform-origin: 50% 50%;
-moz-transform-origin: 50% 50%;
-ms-transform-origin: 50% 50%;
-o-transform-origin: 50% 50%;
transform-origin: 50% 50%;
/* Should be unset in IE9+ I think. */
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
}
Old answer:
For FF 3.5 or Safari/Webkit 3.1, check out: -moz-transform (and -webkit-transform). IE has a Matrix filter(v5.5+), but I'm not certain how to use it. Opera has no transformation capabilities yet.
.rot-neg-90 {
/* rotate -90 deg, not sure if a negative number is supported so I used 270 */
-moz-transform: rotate(270deg);
-moz-transform-origin: 50% 50%;
-webkit-transform: rotate(270deg);
-webkit-transform-origin: 50% 50%;
/* IE support too convoluted for the time I've got on my hands... */
}
CrossBrowser Vertical CSS Text
You can achieve it via transform: rotate()
CSS property, for example:
div { width: 300px; transform-origin: center top; transform: rotate(270deg);}
<div> <h1>First</h1> <h1>Second</h1> <h1>Third</h1></div>
Cross browser vertical centering for text inside a circle
.quantity-badge {
display: block; /*Changed this*/
width: 24px;
height: 24px;
line-height:24px; /*Added this*/
padding:10px; /*Added this*/
text-align: center;
vertical-align: middle;
color: #fff;
border-radius: 50%;
-webkit-border-radius: 50%; /*Added this*/
background-color: #0896ea;
}
I hope this can begin to help you out. Here is a fork of the code you posted: http://codepen.io/anon/pen/EKNevV
Is there a way to just rotate text vertically? Without rotating the whole cell?
You should make a div what is outside the text, and rotate that the other way.
So: If
.VerticalText {
transform: rotate(-90deg);
}
and the div outside is called for example .VerticalTextWrapper
.VerticalTextWrapper {
transform: rotate(90deg);
}
Hope that helps!
Vertical Text with CSS
Specifically for IE, try this:
#myText {
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
}
http://msdn.microsoft.com/en-us/library/ms532918(VS.85).aspx
I'm sorry, but I can't get to IE right now to test versions, but I'm pretty sure it is supported back to IE6.
The ultimate solution to cross-browser vertical centering?
Without an element containing the text, i doubt you will be able to position it dead center like you wish. Once you write proper markup (put the paragraph in a <p>
where it belongs, for instance) it is quite possible though, with the following css;
p {
display: table-cell;
vertical-align: middle;
text-align:center;
}
Also make sure its container (body
in your case) gets display: table; and 100% width/height
Demo at http://jsfiddle.net/sfaVg/3/
Also, a bonus alternative method (requires two containers) can be found at http://zoffix.com/new/absolute-center-random-width-height.html
A third solution, for when you know the dimensions of what you're centering: http://reisio.com/examples/deadcenter/
Vertical Text on a webpage
Modify the th
like this:
<th>
<div class="container">
<div class="head">
<div class="vert">Column 1</div>
</div>
</div>
</th>
<th>
<div class="container">
<div class="head">
<div class="vert">Col 2</div>
</div>
</div>
</th>
<th>
<div class="container">
<div class="head">
<div class="vert">Column Two</div>
</div>
</div>
</th>
And add the CSS provided in the Fiddle and you will get the desired result, I hope.
FIDDLE
javascript / jQuery / CSS - vertical text?
This answer provides a solution that works in IE, Firefox, Opera, and Webkit.
Related Topics
Table Fixed Header and Scrollable Body
Using Flex Order Property to Re-Arrange Items For Desktop and Mobile Views
Why Is 'Position: Sticky' Not Working With Core Ui'S Bootstrap Css
Html5 - Canvas Element - Multiple Layers
Why Can't ≪Fieldset≫ Be Flex Containers
Why Does Overflow:Hidden Not Work in a ≪Td≫
Trouble With Parsing Table Data in Perl
Html Attribute With/Without Quotes
What Does "For" Attribute Do in HTML ≪Label≫ Tag
How to Set the Margin or Padding as Percentage of Height of Parent Container
How to Ignore HTML Element from Tabindex
Html: Include, or Exclude, Optional Closing Tags
Regular Expression to Remove HTML Tags from a String
How to Include an HTML Page into Another HTML Page Without Frame/Iframe
What's the Difference Between Disabled="Disabled" and Readonly="Readonly" for HTML Form Input Fields