Billys Gtr Billys Gtr - 11 months ago 93
CSS Question

CSS transform property with 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)

Answer Source

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

div {
  transform:translate( calc(-100vw + 25vw) );
<div><p>Do not forget !<br/>use prefix if needed !!!</p><p>BTW, i float right</p></div>