Created
December 19, 2018 14:10
-
-
Save vkemeter/a40af68b9e90596176f49ec2c904c43e to your computer and use it in GitHub Desktop.
SCSS Font-Size Idea
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// use sass iteration to set class for every | |
// element in different breakpoints | |
// with different styles | |
@each $elem in map-keys($test) { | |
#{$elem} { | |
@each $breakpoint, $style in _get($test, $elem) { | |
@include media-breakpoint-up(#{$breakpoint}) { | |
@each $k, $v in _get($test, $elem $breakpoint) { | |
#{$k}: #{$v}; | |
} | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// set array with every element wich could have different font sizes | |
// than a global used font-size | |
$test: ( | |
'.test': ( | |
'xs': ( | |
'font-size': 14px, | |
'line-height': 1.2, | |
'margin-bottom': 18px, | |
), | |
'md': ( | |
'font-size': 16px, | |
'line-height': 1.5, | |
'margin-bottom': 20px, | |
), | |
'xl': ( | |
'font-size': 18px, | |
'line-height': 1.8, | |
'margin-bottom': 22px, | |
), | |
) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* should result in this */ | |
.test { | |
font-size: 14px; | |
line-height: 1.2; | |
margin-bottom: 18px; | |
} | |
@media (min-width: 768px) { | |
.test { | |
font-size: 16px; | |
line-height: 1.5; | |
margin-bottom: 20px; | |
} | |
} | |
@media (min-width: 1200px) { | |
.test { | |
font-size: 18px; | |
line-height: 1.8; | |
margin-bottom: 22px; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment