How to write bottom to top vertically with css - html

How to write vertically from bottom to up with HTML and CSS? I have tried many things writing-mod:tb-rl; but the issue not yet solved.

Create a div with class rotate
<div class="rotate"> Hello World </div>
Then define the CSS class
.rotate {
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
transform: rotate(-90deg);
-webkit-transform-origin: 50% 50%;
-moz-transform-origin: 50% 50%;
-ms-transform-origin: 50% 50%;
-o-transform-origin: 50% 50%;
transform-origin: 50% 50%;
}
Hope this is what you are looking for.

try using transforms.
.rotate {
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
}

.rotate {
/* make width fit content */
display: inline-block;
/* rotate 90 degrees counterclockwise */
/* and move down on 100% of its height */
/* (actually width, but when rotated it looks like height) */
transform: rotate(-90deg) translateX(-100%);
/* perform this transformation relatively to the top left corner of block */
transform-origin: top left;
/* styles for demo */
padding: 10px;
background-color: red;
color: #fff;
text-transform: uppercase;
}
<div class="rotate">Profile</div>
But beware that transformed element takes its position the same if it wouldn't be transformed. So in case you'd have some siblings with text it will be overlapping them. Demo:
.rotate {
display: inline-block;
transform: rotate(-90deg) translateX(-100%);
transform-origin: 0 0;
/* just styles for current demo */
padding: 10px;
background-color: red;
color: #fff;
text-transform: uppercase;
}
<div class="container">
<div class="rotate">Profile</div>
<div>Some other text</div>
<div>Some other text</div>
<div>Some other text</div>
</div>
In this case you can apply absolute positioning to this element. Demo:
.container {
/* make absolute positioning relative to container */
position: relative;
/* some offset for its not rotated text */
/* need to be equal rotated element height + offset from rotated element */
padding-left: 45px;
}
.rotate {
display: inline-block;
transform: rotate(-90deg) translateX(-100%);
transform-origin: 0 0;
/* apply absolute positioning */
position: absolute;
/* move element to the left */
left: 0;
/* just styles for demo */
padding: 10px;
background-color: red;
color: #fff;
text-transform: uppercase;
}
<div class="container">
<div class="rotate">Profile</div>
<div>Some other text</div>
<div>Some other text</div>
<div>Some other text</div>
</div>

Related

Sideways header

I've been trying to solve a sideways header problem. I intend on creating a globally sideways header like so on a website: sideways header
However, my problem arises trying to separate the type (it's also breaking on 2 lines). I can't seem to make the vertical line contained or centered within the rectangle . When I resize my browser window it does not stay contained within the rectangle box. I would GREATLY appreciate any suggestions and advice!
What I have so far:
.box {
height: 1326px;
width: 112px;
background-color: transparent;
border: 1px solid #f9f0e4;
}
.bottom {
text-align: center;
color: #000000;
/* Safari */
-webkit-transform: rotate(-90deg);
/* Firefox */
-moz-transform: rotate(-90deg);
/* IE */
-ms-transform: rotate(-90deg);
/* Opera */
-o-transform: rotate(-90deg);
/* Internet Explorer */
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
}
.top {
text-align: center;
color: #000000;
/* Safari */
-webkit-transform: rotate(-90deg);
/* Firefox */
-moz-transform: rotate(-90deg);
/* IE */
-ms-transform: rotate(-90deg);
/* Opera */
-o-transform: rotate(-90deg);
/* Internet Explorer */
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
}
.vl {
border-left: 1px solid #f9f0e4;
height: 620px;
position: absolute;
left: 50%;
top: 0;
}
<div class="container">
<div class="box">
<p class="bottom">CREATIVE STUDIO</p>
<div class="vl">
<p class="top">FLORENCE — ITALY</p>
</div>
</div>
</div>
You can instead consider rotation on the whole box and use vh unit so the width is relative to height since it's getting rotated :
.box {
background-color: transparent;
width: 80vh;
border: 1px solid;
transform: rotate(-90deg) translate(-50%, 0);
transform-origin: center;
}
.box {
display: flex;
justify-content: space-between;
text-align: center;
color: #000000;
}
.bottom {
text-align: center;
color: #000000;
margin-left: 10px;
}
.top {
text-align: center;
color: #000000;
margin-right: 10px;
}
<div class="box">
<p class="bottom">CREATIVE STUDIO</p>
<p class="top">FLORENCE — ITALY</p>
</div>

How to center rotated text?

What is the best way to center the rotated text (270deg) in current situation? It is currently position relatively but it isn't a very good solution.
HTML:
<div id="side" class="container">
<p id="sidetext" >Work</p>
</div>
<div id="cont" class="container">
<div id="row" class="row">
Hey yeah!
</div>
</div
And CSS:
#sidetext {
font-family: "Josefin Sans";
text-transform: uppercase;
display: block;
font-weight: 100;
font-size: 1.7em;
color: white;
-webkit-transform: rotate(270deg);
-moz-transform: rotate(270deg);
-o-transform: rotate(270deg);
-ms-transform: rotate(270deg);
transform: rotate(270deg);
transform: rotate(270deg);
position: relative;
top: 216px;
margin: 0 22px 10px;
}
you can try this css.
.tab-caption {
position: absolute;
top: 50%;
height: 2px; /* actual text will overlap! */
margin-top: -1px; /* subtract half the height */
line-height: 0px; /* centre the text on the base line */
text-align: center;
left: 50%; /* added */
transform: translateX(-50%) rotate(90deg); /* added translateX */
white-space: nowrap;
}

Using CSS to vertically rotate from it's original top left not the center axis

How do you vertically rotate text on IE8+
The elements I want to vertically rotate are positioned absolutely and require to be in the same place.
<div id="parent">
<div id="child_1">
</div>
<div id="child_2">
</div>
</div>
CSS:
#parent {
position: absolute;
width: 300px;
height: 300px;
}
#child_1 {
postion: absolute;
top: 250px;
left: 50px;
width: 100px;
height: 10px;
}
#child_2 {
postion: absolute;
top: 200px;
left: 10px;
width: 100px;
height: 10px;
}
There is a hack for IE8 using filter however this requires positioning of element for IE separately but I can live with this.
IE8:
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
IE9+:
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
transform: rotate(-90deg);

90 degrees rotated text, flush to page top-right with CSS

I know how to rotate text 90 degrees using CSS, but I'm trying to align the text to the top-right of the page (or a parent element) as its 90-degree-rotated self. Is this possible?
Example:
Neither of the previous solutions work for any amount of text. You need to use transform-origin.
<div class="container">
<span class="rotate">Hello THERE!</span>
</div>
.rotate {
-webkit-transform: rotate(90deg);
-webkit-transform-origin: left top;
-moz-transform: rotate(90deg);
-moz-transform-origin: left top;
-ms-transform: rotate(90deg);
-ms-transform-origin: left top;
-o-transform: rotate(90deg);
-o-transform-origin: left top;
transform: rotate(90deg);
transform-origin: left top;
position: absolute;
top: 0;
left: 100%;
white-space: nowrap;
font-size: 48px;
}
My first time answering something very new to this but here is the code:
<div id="block">
<p id="rotate">Hello!!!</p>
</div>
<style>
#block{
width:500px;
height:500px;
display:block;
margin:auto;
border: 1px solid #000;
position:absolute;
}
#rotate {
position:relative;/* place the text relateve to whatever tag is devined as absolute */
left:130px;/* change these dimensions - can use left or right */
top:20px;/* change these dimensions can use top or bottom*/
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
}
</style>
The solution is simple,add the rotation in text and position absolute.
<style>
#block{
width:500px;
height:500px;
display:block;
margin:auto;
border: 1px solid #000;
position:relative;
}
#text {
padding:0;
margin:0;
position:absolute;
right:0;
font-size:30px;
top:40px;
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
}
</style>
<div id="container">
<p id="text">Hello!!!</p>
</div>

Float right a fixed div and rotate it

I am trying to rotate this div, fix it and float it to the RIGHT like this [jsbin.com/ujebik/1][1] but it don't completely float to the RIGHT
HTML:
<div class="logo">
ROTATE THIS TEXT
</div>
CSS:
.logo {
position: fixed;
top: 20px;
right: 0;
z-index: 100;
width: 250px;
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
transform: rotate(-90deg);
font-size:20px;
background-color:green
}
UPDATE:
want this:
but Have this:
Try to add transform-origin: 100% 100%; to make the div rotate around its lower right corner instead of its center (http://jsbin.com/iniweq/2/)
I am guessing what you are trying to do is have the element on the left? If this is the case then you need to change your CSS to
.logo {
position: fixed;
top: 20px;
left: 0;
z-index: 100;
width: 250px;
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
transform: rotate(-90deg);
font-size:20px;
background-color:green
}
Here is a fiddle: http://jsfiddle.net/Er3yL/
Or if what you are trying to say is that you want to 'float' it to the extreme RIGHT, then I am guessing that the parent element for .logo is not stretched to 100% of the window. Either you can correct that or if you want to keep it that way then you can add a negative value to right, like this
.logo {
position: fixed;
top: 20px;
right: -20px;
z-index: 100;
width: 250px;
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
transform: rotate(-90deg);
font-size:20px;
background-color:green
}