森秋彩 努力の天才
多くの人が待ち望んだシニア国際大会デビュー。世界選手権では得意のリードで日本人最年少メダルを獲得。幼い頃から数々の大会を制してきた16歳は、どのような心境で2019年シーズンを過ごしてきたのか。まだ幼さの残る表情から見えてきたのは、絶え間ない向上心。クライミングの天才少女は、努力の天才だった。
By Chen Hui Jing / @hj_chen
$base-color: #c6538c;
$border-dark: rgba($base-color, 0.88);
.alert {
border: 1px solid $border-dark;
}
@link-color: #428bca;
@link-color-hover: darken(@link-color, 10%);
.link {
color: @link-color;
}
.link:hover {
color: @link-color-hover;
}
font-size = 14px
font-stack = "Lucida Grande", Arial, sans-serif
body
font font-size font-stack
Source SCSS
$accent-colour: cornflowerblue;
.card {
border: 2px dashed $accent-colour;
}
$accent-colour: palegreen;
.cta {
box-shadow: 0 5px 15px 5px $accent-colour;
}
Compiled CSS
.card {
border: 2px dashed cornflowerblue;
}
.cta {
box-shadow: 0 5px 15px 5px palegreen;
}
A custom property is any property whose name starts with two dashes (U+002D HYPHEN-MINUS), like --dinosaur
.
--*
It will be used to define the substitution value of var()
functions.
Acceptable 🙆🏻♀️
:root {
--dinosaur: firebrick;
--42: orange;
--waterMelon: lightcoral;
--watermelon: gold;
----c4tz: forestgreen;
--_pirate: gold;
}
Sorry, but no 🙅🏻♀️
--angels: pink; // not in a selector
:root {
fruit: tomato; // no dash, doesn't work
-flower: orchid; // single dash, also cannot
// special characters are generally a no
--$cargopants: olive;
--@weather: skyblue;
--bread&butter: lemonchiffon;
}
var()
notationvar( <custom-property-name> , <declaration-value>? )
where <custom-property-name>
is the double-dash prefixed property, and declaration-value
is the optional fall-back
var()
notationThe fallback value kicks in if the custom property value is undefined
Hello, I am a p element with a class of a-sentence
in a div with the class a-box
.
b-box
.
多くの人が待ち望んだシニア国際大会デビュー。世界選手権では得意のリードで日本人最年少メダルを獲得。幼い頃から数々の大会を制してきた16歳は、どのような心境で2019年シーズンを過ごしてきたのか。まだ幼さの残る表情から見えてきたのは、絶え間ない向上心。クライミングの天才少女は、努力の天才だった。
Data attributes are useful for theming, localStorage
can be used for persistence
See the Pen Untitled by Chen Hui Jing (@huijing) on CodePen.
Hello, this is a frame without any themes applied.
Hello, this is a frame with the class theme-1
.
Hello, this is a frame with the class theme-2
.
radial-gradient( [ <ending-shape> || <size> ]? [ at <position> ]? , <color-stop-list> )
Solar
Moonbyul
Wheein
Hwasa
calc()
See the Pen Untitled by Chen Hui Jing (@huijing) on CodePen.
@mixin defineColorHSL($color, $hue, $saturation, $lightness){
#{$color}: unquote("hsl(#{$hue}, #{$saturation}, #{$lightness})");#{$color}-h: #{$hue};#{$color}-s: #{$saturation};#{$color}-l: #{$lightness};
}
:root, [data-theme="default"] {
@include defineColorHSL(--color-primary, 220, 89%, 56%);
@include defineColorHSL(--color-accent, 355, 90%, 61%);
@include defineColorHSL(--color-black, 240, 8%, 12%);
@include defineColorHSL(--color-white, 0, 0%, 100%);
}
.component {
background-color: alpha(var(--color-primary), 0.2); // it works 🎉
}
@function lightness($color, $lightnessMultiplier){
$color: str-replace($color, 'var(');
$color: str-replace($color, ')');
$color-h: var(#{$color+'-h'});
$color-s: var(#{$color+'-s'});
$color-l: var(#{$color+'-l'});
@return hsl($color-h, $color-s, calc(#{$color-l} * #{$lightnessMultiplier}));
}
.component {
background-color: lightness(var(--color-primary), 1.2);
}
How to combine SASS color functions and CSS Variables
// get variable value from element
getComputedStyle(element).getPropertyValue('--variable-name')
// set variable value
element.style.setProperty('--variable-name', 'RELEVANT_PROPERTY_VALUE');
See the Pen Untitled by Chen Hui Jing (@huijing) on CodePen.
// get variable value from element
getComputedStyle(element).getPropertyValue('--variable-name')
// set variable value
element.style.setProperty('--variable-name', 'RELEVANT_PROPERTY_VALUE');
See the Pen Naive colour change on mousemove by Chen Hui Jing (@huijing) on CodePen.
@property
at-ruleThe @property
rule represents a custom property registration directly in a stylesheet without having to run any JS.
@property --property-name {
syntax: "<color>";
inherits: false;
initial-value: #c0ffee;
}