4 ms·
Fortunately, you can use a pre-processor like SASS for that -- however, calc() allows you to do calculations at runtime which cannot be done in a pre-processor.
by fortes 16y ago
Fortunately, you can use a pre-processor like SASS for that -- however, calc() allows you to do calculations at runtime which cannot be done in a pre-processor.
- nex3 16y agoWe'll be looking into compiling certain Sass calculations that can't be done at compile time, such as "3px + 3%", into uses of calc().
- tjpick 16y agoor use any of the various scripting languages (php, python, perl etc) to serve the css. Problem solved. Just do this behind a cgi or similar for development, and then just run it and save the output as a static file for production. It's not like variables in a plain text string are a hard thing, for goodness sake.
- chime 16y agowidth: 100% - 2px cannot be done via PHP. That's why this is very interesting. 100% changes depending on your browser window size.
- tjpick 16y agowell yes, but I was responding to the following from the GP, rather than discussing the power of calc() > I rather have vars or defs so I can declare a color once...
- pbhjpbhj 16y agoI'm pretty sure anyone here will realise this - it's just that it would be better if it were implemented in the spec, I'm amazed that colour definitions aren't in CSS3.