Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS transform property with calc [duplicate]

Tags:

css

css-calc

I want to make a calculation for the transform property. Is it possible to use the calc feature for that?

Something like:

 width: calc(100vw-2vw);

but for transform

 transform: translate(calc(100vw-2vw));

(Of course the above is not functional)

like image 404
Bill Avatar asked Dec 07 '25 09:12

Bill


1 Answers

It works if you respect a white space in between calc values and signed used : transform: translate(calc(100vw - 2vw));

div {
  border:solid;
  float:right;
  height:20vw;
  width:20vw;
  transform:translate( calc(-100vw + 25vw) );
}
<div><p>Do not forget !<br/>use prefix if needed !!!</p><p>BTW, i float right</p></div>
like image 64
G-Cyrillus Avatar answered Dec 08 '25 21:12

G-Cyrillus