Suppose I have two transformations in the transform property , Ex:
transform: scale(.5,.5) rotate(10deg);
I know that it is possible to set the origin point of the transformations using the property transform-origin
, eg:
transform-origin: 0 0;
But that origin point will apply for all transformations of the object.
Is there a way to indicate a different origin point for each transformation?
Example using the method that indicates rnd
* {
margin:0px;
padding:0px;
}
#a{
background-color:green;
width:100px;
height:100px;
display: block;
transition:1s;
transition-timing-function: linear;
transform-origin: left top 0;
}
#a:hover{
transform:scale(.5);
}
#b {
width:100px;
height:100px;
transition:1s;
transition-timing-function: linear;
background-color:red;
transform-origin: right top 0;
}
#b:hover {
transform: rotate(-90deg);
}
<div id="a"><div id="b"></div></div>
You can't, but you can always use two different elements, and give each one a different origin.
According to the W3C documentation , you can only specify a single
transform-origin
which can have one of the following formats:That is, the value of
tranform-origin
can have 1, 2 or 3 parameters but it will be a single value (and not a list of values) that will be applied totransform
(which can be a list).So answering your question: no, there is no way to indicate a different origin point for each transformation because only one value is allowed, which will be applied to all the transformations indicated in
transform
.