Understanding CSS rotate3d axis of rotation - html

I am having trouble understanding css rotate3d method. Could someone please explain how the axis of rotation is obtained from the x, y, and z values since they are not given in degrees?

3D rotate mean in 3 direction.
First, you must be understand Rotate.
#myDiv {
-webkit-transform: rotateX(150deg); /* Safari */
transform: rotateX(150deg);
}
rotateY()
#myDiv {
-webkit-transform: rotateY(130deg); /* Safari */
transform: rotateY(130deg);
}
rotateZ()
#myDiv {
-webkit-transform: rotateZ(90deg); /* Safari */
transform: rotateZ(90deg);
}
It is just an example, you use these three properties to make 3D rotate.

Related

CSS - add transform to element without removing the existing one [duplicate]

This question already has answers here:
How can I apply multiple transform declarations to one element?
(5 answers)
Closed 6 years ago.
So, I have a div, like this:
<div class="rotate-90"></div>
and the css:
.rotate-90
{
transform: rotate(90deg);
}
and I want to add another class to the div, named "scale-2", like this:
<div class="rotate-90 scale-2"></div>
.scale-2
{
transform: scale(2);
}
but when I try to combine them, the second class overrides the first one, so I get only a scaled div, and not rotated.
So, how can I combine the transforms without writing the code twice or combining the classes codes?
Thanks :)
Update 2022
At the end of last year the W3C published the working draft for "CSS Transforms Module Level 2".
This spec adds new transform functions and properties for three-dimensional transforms, and convenience functions for simple transforms.
It adds "Individual Transforms":
translate
scale
rotate
As the browser-support is over 85% it should be usable, if your project does not have to support old browsers.
So you should be able to do this from now on:
.rotate-90
{
rotate: 90deg;
}
.scale-2
{
scale: 2;
}
Here is a nice introduction-video:
"A new way to do CSS transforms!" by Kevin Powell.
Original Answer:
Transform-rules get overridden, like any other rules.
You can however combine the transforms in one rule:
.rotate-90.scale-2 {
transform: rotate(90deg) scale(2);
}
If combining the two classes isn't your wish (which I totally don't understand, but respect), and if your framework only has these two effects, than you could use zoom for the scale-rule:
.scale-2 {
zoom: 2;
}
Because you are using transform property again and its overriding previous one.
You can use both in one transform like this
.rotate-90.scale-2 {
transform: rotate(90deg) scale(2);
}
Transform property should be used with prefix to let it work in all browsers like this
.rotate-90.scale-2 {
transform: rotate(90deg) scale(2);
-moz-transform: rotate(90deg) scale(2);
-ms-transform: rotate(90deg) scale(2);
-webkit-transform: rotate(90deg) scale(2);
-o-transform: rotate(90deg) scale(2);
}

Is there a way to change the different dimensions (x,y) of font-size?

div {
font-size:1.2em;
}
This looks like it changes both the xy coordinates of a font. Is there any way I can independently modify the x and y coordinates of a font?
For example:
div {
font-size-y:1.6em;
font-size-x:1.2em;
}
(this would make the font taller)
Possible, or no?
There are not font-size-x or font-size-y styling rules. There are however transforms for size, scale and location. You could do something like this to achieve what you want.
div {
-ms-transform: scale(1.0, 2.0);
/* IE 9 */
-webkit-transform: scale(1.0, 2.0);
/* Chrome, Safari, Opera */
transform: scale(1.0, 2.0);
}
<div>
Hello World
</div>

Rotating CSS 3 Shapes

Are there any ways to rotate CSS 3 shapes at a certain angle?
Dabblet code here.
.shape
{
transform:rotate(150deg);
-ms-transform:rotate(150deg); /* IE 9 */
-webkit-transform:rotate(150deg); /* Opera, Chrome, and Safari */
}
Add transform:rotate to your id octagon.
Refer this link: http://davidwalsh.name/css-transform-rotate
.object {
transform: rotate(45deg);
}
You can also set the transform-origin:
object {
transform: rotate(45deg);
transform-origin: left;
}
You can change the position to left, right, top or bottom depending on how you want the object to rotate.
Hope this helps!

Skew a paragraph in css but keep each line left justified

I'm trying to skew some text that sits within a div, which is all nice a straight forward, but I am trying to find a way to keep each line completely left justified to one side of the div, as currently the first few lines sit in so many pixels and the last few lines overflow out. The font we're using is already italic but we want to push it a little more with the skew, I know it's not going to look perfect but it works for what we want.
Is there a way to do this? I've tried searching one out already but I'm not sure if I'm looking for the right thing or it's something that's nobody bothers doing.
Heres a basic JSfiddle
and an awful mock up... bad mockup
and the basic code to test it out...
Here is the CSS:
.box {
width:600px;
height:300px;
background:#f1f1f1;
}
.box p {
transform: skew(-20deg);
-ms-transform: skew(-20deg); /* IE 9 */
-moz-transform: skew(-20deg); /* Firefox */
-webkit-transform: skew(-20deg); /* Safari and Chrome */
-o-transform: skew(-20deg); /* Opera */
}
And the HTML:
<div class="box">
<p>Text here - more in the fiddle</p>
</div>
Thanks guys!
This may be a silly question, but are you simply wanting italic text? If that's the case, and your font is italic by default as you say, simply remove the skew completely and give your .box p selector font-style: italic:
.box p {
font-style: italic;
}
JSFiddle demo.
If you are wanting the text's container to be skewed, however, what you can do is introduce a container element and apply the skew on that:
<article>
<p>...</p>
</article>
.box article {
transform: skew(-20deg);
-ms-transform: skew(-20deg); /* IE 9 */
-moz-transform: skew(-20deg); /* Firefox */
-webkit-transform: skew(-20deg); /* Safari and Chrome */
-o-transform: skew(-20deg); /* Opera */
}
Now simply counter that skew on your p element by skewing the same amount in the opposite direction:
.box article p {
font-style: italic;
transform: skew(20deg);
-ms-transform: skew(20deg); /* IE 9 */
-moz-transform: skew(20deg); /* Firefox */
-webkit-transform: skew(20deg); /* Safari and Chrome */
-o-transform: skew(20deg); /* Opera */
}
Here I've again added font-style: italic to make the text render italic.
JSFiddle demo.

Automatically zoom out the whole website on Magento?

is there a way to make my website automatically zoom out to 90% ?
Thanks
This can be done with css3 scale attribute but beware that this is not support on all browsers.
http://www.w3schools.com/css3/css3_2dtransforms.asp/
body{
transform: scale(0.9);
-ms-transform: scale(0.9); /* IE 9 */
-webkit-transform: scale(0.9); /* Safari and Chrome */
-o-transform: scale(0.9); /* Firefox */
}
Or with jquery and javascript for cross browser by appending a div around the content off the site and scaling to 90% off the body width;
Something roughly like
var bdwidth = $("body").width();
$("wrapper").width((bdwidth / 100)*90);
Use CSS
body {
-moz-transform: scale(0.9, 0.9); /* Moz-browsers */
zoom: 0.9; /* Other non-webkit browsers */
zoom: 90%; /* Webkit browsers */
}
This worked for me!