V
V
Vitaly Kononenko2016-02-26 22:53:02
Sass
Vitaly Kononenko, 2016-02-26 22:53:02

Write a mixin or function for scss?

Once I wrote like this - font: 14px/21px Arial,sans-serif;
And how to write in rem c foul backs in pixels
i.e.
scss -> font: rem(14)/rem(21) $some-var-font;
css -> font: 14px/21px Arial,sans-serif;
font: 0.85rem/1.3125rem Arial,sans-serif;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2016-02-27
@rushOneToster

something like this

$GLOBAL_FONT_SIZE: 18px; // this should be with 'px'

@mixin my-font ($font_size, $lineheight_size, $font){
  font: #{ $font_size * $GLOBAL_FONT_SIZE }/#{ $lineheight_size * $GLOBAL_FONT_SIZE } $font;
  font: #{ $font_size }rem/#{ $lineheight_size }rem $font;
}

.somestyle {
    @include my-font(1, 1.5, 'Arial sans-serif');
}

.somestyle {
  font: 18px/27px "Arial sans-serif";
  font: 1rem/1.5rem "Arial sans-serif";
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question