Can I use the CSS calc function to subtract a percentage from a percentage? Example: margin-left:calc(100% – 14%);
This is what I tried calc(100% – (6 * 12%)). I have 6 boxes with with being 12% of the container they are in.
Can I use the CSS calc function to subtract a percentage from a percentage? Example: margin-left:calc(100% – 14%);
This is what I tried calc(100% – (6 * 12%)). I have 6 boxes with with being 12% of the container they are in.
2
Answers
example paste this in your html page
you can tweak your calculation according to the above example.
Yes, you can absolutely use the cal() function in css to subtract percentage from percentages.your example is valid.
For your specific case with 6 boxes each being 12% of the container width, if you want to subtract 12% six times from 100%, you can do it like this:
margin-left: calc(100% – (6 * 12%));