_px2em.scss 566B

1234567891011121314151617181920212223242526272829303132
  1. @charset "UTF-8";
  2. //un-modified
  3. @function calc-em($target-px, $context) {
  4. @return ($target-px / $context) * 1em;
  5. }
  6. // and modified to accept a base context variable
  7. $browser-context: 16;
  8. @function em($pixels, $context: $browser-context) {
  9. @return ($pixels / $context) * 1em;
  10. }
  11. @function rem($pixels, $context: $browser-context) {
  12. @return ($pixels / $context) * 1rem;
  13. }
  14. @function font-size($size) {
  15. @return em($size);
  16. }
  17. @mixin em($size) {
  18. font-size: $size;
  19. font-size: em($size);
  20. }
  21. @mixin rem($size) {
  22. font-size: $size;
  23. font-size: rem($size);
  24. }