How to rotate some text in html css? - html

I want to do something like this.
I dont know the property of css should be used.
my code is:
<h1><b>#GIRLBOSSES</b></h1>
CSS:
h1 b {
position: absolute;
color: #fdd2e9;
margin-left: 127px;
margin-top: 191px;
}

You need several settings. Different for different browsers.
.rotate {
-ms-transform: rotate(7deg); /* IE 9 */
-webkit-transform: rotate(7deg); /* Chrome, Safari, Opera */
transform: rotate(7deg);
}
Look in JSfiddle:
https://jsfiddle.net/z5dcnrwa/

you can use css transform to do that
h1{
transform: rotate(-18deg);
transform-origin: top left;
}

Test live
h1 {
-ms-transform: rotate(-9deg); /* IE 9 */
-webkit-transform: rotate(-9deg); /* Chrome, Safari, Opera */
transform: rotate(-9deg);
}
Edit: In the title of the post you asked about vertical text. For vertical, set it to -90.

You are looking for the CSS3 transform Property. In your case, it would look something like this:
<h1 style="position: absolute; color: #fdd2e9; margin-left: 127px; margin-top: 191px; -ms-transform: rotate(-7deg); -webkit-transform: rotate(-7deg); transform: rotate(-7deg);"><b>#GIRLBOSSES</b></h1>
The operative styles are:
-ms-transform: rotate(-7deg); /* IE 9 */
-webkit-transform: rotate(-7deg); /* Chrome, Safari, Opera */
transform: rotate(-7deg);

Do you want something like this?
.tilted {
position: absolute;
color: #fdd2e9;
left: 50%;
top: 10%;
font-size:50px;
-webkit-transform: rotate(-8deg);
-ms-transform: rotate(-8deg);
transform: rotate(-8deg);
}
.wrap {
position: relative;
display: inline-block;
}
<div class="wrap">
<img src="http://lorempixel.com/400/200/" />
<h1 class="tilted"><b>#GIRLBOSSES</b></h1>
</div>

Related

how twelve point star works correctly?

I am new to front-end developer and I am learning css basics , I can understand the following code
#twelve-point-star {
height: 100px;
width: 100px;
margin: 30px;
background: blue;
position: absolute;
}
#twelve-point-star:before {
height: 100px;
width: 100px;
background: blue;
content: "";
position: absolute;
/* Rotate */
-moz-transform: rotate(30deg);
-webkit-transform: rotate(30deg);
-ms-transform: rotate(30deg);
-o-transform: rotate(30deg);
transform: rotate(30deg);
}
#twelve-point-star:after {
height: 100px;
width: 100px;
background: blue;
content: "";
position: absolute;
/* Rotate */
-moz-transform: rotate(-30deg);
-webkit-transform: rotate(-30deg);
-ms-transform: rotate(-30deg);
-o-transform: rotate(-30deg);
transform: rotate(-30deg);
}
<p>twelve point star</p>
<div id="twelve-point-star"></div>
We have created a different kind of triangle and rotate that position to achieve this position. But what purpose we used :before and :after ?
See...you need total 12 stars. If you apply css only #twelve-point-star, you will get 4 corners...you need 8 corners more...For that you have used the :before to get 4 corners more and :after to get final 4 corners pseudo classes to get total 12 corners..
Try to change the color you will see the real visual.
Stack Snippet
#twelve-point-star {
height: 100px;
width: 100px;
margin:30px;
background: blue;
position: absolute;
}
#twelve-point-star:before {
height: 100px;
width: 100px;
background: red;
content:"";
position: absolute;
/* Rotate */
-moz-transform: rotate(30deg);
-webkit-transform: rotate(30deg);
-ms-transform: rotate(30deg);
-o-transform: rotate(30deg);
transform: rotate(30deg);
}
#twelve-point-star:after {
height: 100px;
width: 100px;
background: black;
content:"";
position: absolute;
/* Rotate */
-moz-transform: rotate(-30deg);
-webkit-transform: rotate(-30deg);
-ms-transform: rotate(-30deg);
-o-transform: rotate(-30deg);
transform: rotate(-30deg);
}
<body>
<p>
twelve point star
</p>
<div id="twelve-point-star">
</div>
</body>
Reference Link
::before
::after
:before
means that before every #twelve-point-star, the css in #twelve-point-star:before will be applied to #twelve-point-star. Likewise for :after, except that it is place after every #twelve-point-star. So what happens in the code is that you basically make 3 squares that are rotated in different directions, which creates that effect.
W3schools is a great source for you to learn css.

CSS rotate animation translates the element

I'm having trouble (again) understanding CSS animations- specifically this rotate animation. When you hover over the image it should start to rotate back-and-forth. It does this, but only after shifting over to the bottom left. I've been looking for similar questions but haven't found an answer as to why this happens or how to prevent it.
img {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
img:hover {
animation-name: freakout;
animation-duration: .5s;
animation-iteration-count: infinite;
}
#keyframes freakout {
0%, 100% {
-ms-transform: rotate(0deg);
/* IE 9 */
-webkit-transform: rotate(0deg);
/* Chrome, Safari, Opera */
transform: rotate(0deg);
}
50% {
-ms-transform: rotate(7deg);
/* IE 9 */
-webkit-transform: rotate(7deg);
/* Chrome, Safari, Opera */
transform: rotate(7deg);
}
}
<img src="http://www.swimwithamanatee.biz/normal_ian-symbol-trichechus-spp22_left.png" />
Reason behind this is that in img tag Transform property uses Translate function so as to align the image to center but the moment you hover over the image the Transform property changes to Rotate property resulting in shifting of position while hovering over the image.I changed the code ,This will work.
img {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
img:hover {
animation-name: freakout;
animation-duration: .5s;
animation-iteration-count: infinite;
}
#keyframes freakout {
0%, 100% {
-ms-transform: rotate(0deg)translate(-50%, -50%);
/* IE 9 */
-webkit-transform: rotate(0deg)translate(-50%, -50%);
/* Chrome, Safari, Opera */
transform: rotate(0deg)translate(-50%, -50%);
}
50% {
-ms-transform: rotate(7deg)translate(-50%, -50%);
/* IE 9 */
-webkit-transform: rotate(7deg)translate(-50%, -50%);
/* Chrome, Safari, Opera */
transform: rotate(7deg)translate(-50%, -50%);
}
}
<img src="http://www.swimwithamanatee.biz/normal_ian-symbol-trichechus-spp22_left.png" />

Trying to create this shape and animate the red in css and html alone

.reddiv {
background: #FF0000;
border-radius: 50%;
display: block;
height: 60px;
width: 60px;
}
.reddiv::after {
content:"\2193"; /* The code for the arrow : see the reference */
display: block;
color: white;
font-weight: bolder;
font-size: 40px; /* Adjust for your needs */
text-align: center;
}
This is the plnk url
http://plnkr.co/edit/lSh4cGgT4lRorQd4Lg6s?p=preview
I am unable to understand on how to proceed further
Use it in a single animation and use transform rotate.
#keyframes slidedown {
0% {
margin-top: 0;
}
30%{
margin-top: 300px;
-ms-transform: rotate(0deg); /* IE 9 */
-webkit-transform: rotate(0deg); /* Chrome, Safari, Opera */
transform: rotate(0deg);
}
60% {
-ms-transform: rotate(-90deg); /* IE 9 */
-webkit-transform: rotate(-90deg); /* Chrome, Safari, Opera */
transform: rotate(-90deg);
margin-top: 300px;
margin-left: 0;
}
100%{
-ms-transform: rotate(-90deg); /* IE 9 */
-webkit-transform: rotate(-90deg); /* Chrome, Safari, Opera */
transform: rotate(-90deg);
margin-top: 300px;
margin-left: 300px;
}
}
Here is a the forked plnk

Display text differently on div

I have the following code which displays text vertically.FIDDLE
<div id="btn-toggle-menu">
M
e
n
u
</div>
CSS:
#btn-toggle-menu {
top:0;
left:0;
width:20px;
cursor:pointer;
font-weight:bold;
background-color:#ccc;
text-align:center;
white-space: pre;
}
O/P:
I want the text to be displayed like the one which points to Required menu text. Can someone give me a demo fiddle?
check this link
css
#btn-toggle-menu {
top:0;
left:0;
width:20px;
height:500px;
cursor:pointer;
font-weight:bold;
background-color:#ccc;
text-align:center;
white-space: pre;
vertical-align:middle;
}
#inner-div
{
-webkit-transform:rotate(-90deg);
-moz-transform:rotate(-90deg);
-o-transform: rotate(-90deg);
white-space:nowrap;
margin-top:150px;
}
Add a span with this class (or change css selector), this should do it
.textWrapper{
background: #FFF;
display: inline-block; /* inline doenst work, block seems to make it switch CC<->CCW */
-moz-transform:rotate(90deg); /* FireFox*/
-webkit-transform:rotate(90deg); /* Safari and Chrome */
-o-transform:rotate(90deg); /* Opera */
-ms-transform:rotate(90deg); /* IE9 */
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=0.7071067811865476, M12=-0.7071067811865475, M21=0.7071067811865475, M22=0.7071067811865476)"; /* IE8 */
transform: rotate(90deg);/* The way it should work: */
}
This will probably turn the wrong way, just change it to -90, or 270 degrees.
Bear in mind that IE8 doesnt do very will in odd numbers (like 67), stick to 45degree steps to avoid that
I did not add code for IE7 or older, those should be burned without mercy.
Very simple fiddle: http://jsfiddle.net/DqTe6/1/ . This doesnt improve the font. You might need to go with an image.
Normally I prefer text over image, but the text 'menu' has no SEO value whatsoever
<div id="btn-toggle-menu">
<p class="text">Menu</p>
</div>
.text
{
-moz-transform: rotate(-90.0deg); /* FF3.5+ */
-o-transform: rotate(-90.0deg); /* Opera 10.5 */
-webkit-transform: rotate(-90.0deg); /* Saf3.1+, Chrome */
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=0.083);
/* IE6,IE7 */
-ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=0.083)";
}
Fiddle:
http://jsfiddle.net/VmH5g/
Try this,
HTML
<div class="bg">
<div id="btn-toggle-menu">Menu</div>
</div>
CSS
#btn-toggle-menu {
background-color: #FFFFFF;
cursor: pointer;
font-weight: bold;
height: 20px;
left: -10px;
position: absolute;
text-align: center;
top: 40%;
width: 40px;
/* white-space: pre;*/ /* 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);
}
.bg{background-color:#ccc;height:100px;width:20px;position:relative}
Fiddle http://jsfiddle.net/FWzAS/35/
Refer http://css-tricks.com/snippets/css/text-rotation/
Do you mean like this?
-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%;
Click here for demo
Live Demo
use belo CSS in your code:
-webkit-transform: rotate(-90deg);
-ff-transform: rotate(-90deg);
transform: rotate(-90deg);
Here you go..
Slightly modified version of #Martijn's answer.
http://jsfiddle.net/SmtCS/
CSS
.textWrapper{
background: #FFF;
/* FireFox*/
-moz-transform:rotate(270deg);
/* Safari and Chrome */
-webkit-transform:rotate(270deg);
/* Opera */
-o-transform:rotate(270deg);
/* IE9 */
-ms-transform:rotate(270deg);
/* IE8 */
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=0.7071067811865476, M12=-0.7071067811865475, M21=0.7071067811865475, M22=0.7071067811865476)";
}
HTML
<div id="btn-toggle-menu" class="btn textWrapper">M e n u </div>
Try the JS fiddle
http://jsfiddle.net/jWJMn/
.element {
-moz-transform: rotate(270deg);
-webkit-transform: rotate(270deg) ;
-o-transform: rotate(270deg) ;
-ms-transform: rotate(270deg) ;
transform: rotate(270deg);
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=1);
background-color:yellow;
height:50px;
width:50px;
}

How to rotate a <div> 90 degrees?

I have a <div> that I want to rotate 90 degrees:
<div id="container_2"></div>
How can I do this?
You need CSS to achieve this, e.g.:
#container_2 {
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-o-transform: rotate(90deg);
-ms-transform: rotate(90deg);
transform: rotate(90deg);
}
Demo:
#container_2 {
width: 100px;
height: 100px;
border: 1px solid red;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-o-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
}
<div id="container_2"></div>
(There's 45 degrees rotation in the demo, so you can see the effect)
Note: The -o- and -moz- prefixes are no longer relevant and probably not required. IE9 requires -ms- and Safari and the Android browser require -webkit-
Update 2018: Vendor prefixes are not needed anymore. Only transform is sufficient. (thanks #rinogo)
Use following in your CSS
div {
-webkit-transform: rotate(90deg); /* Safari and Chrome */
-moz-transform: rotate(90deg); /* Firefox */
-ms-transform: rotate(90deg); /* IE 9 */
-o-transform: rotate(90deg); /* Opera */
transform: rotate(90deg);
}
Use transform: rotate(90deg):
#container_2 {
border: 1px solid;
padding: .5em;
width: 5em;
height: 5em;
transition: .3s all; /* rotate gradually instead of instantly */
}
#container_2:hover {
-webkit-transform: rotate(90deg); /* to support Safari and Android browser */
-ms-transform: rotate(90deg); /* to support IE 9 */
transform: rotate(90deg);
}
<div id="container_2">This box should be rotated 90° on hover.</div>
Click "Run code snippet", then hover over the box to see the effect of the transform.
Realistically, no other prefixed entries are needed. See Can I use CSS3 Transforms?
Use the css "rotate()" method:
div {
width: 100px;
height: 100px;
background-color: yellow;
border: 1px solid black;
}
div#rotate{
transform: rotate(90deg);
}
<div>
normal div
</div>
<br>
<div id="rotate">
This div is rotated 90 degrees
</div>
you can use css3 property writing-mode
writing-mode: tb-rl
css-tricks
mozilla
We can add the following to a particular tag in CSS:
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-o-transform: rotate(90deg);
-ms-transform: rotate(90deg);
transform: rotate(90deg);
In case of half rotation change 90 to 45.