{"id":314874,"date":"2020-12-15T03:00:52","date_gmt":"2020-12-15T03:00:52","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=314874"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=314874","title":{"rendered":"CSS var \u0432 rgba \u0438\u043b\u0438 \u0443\u0434\u043e\u0431\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0446\u0432\u0435\u0442\u043e\u0432 \u0432 Sass"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u0430 \u043e\u0431\u0437\u043e\u0440\u0443 \u043c\u043e\u0438\u0445 \u043d\u0430\u0440\u0430\u0431\u043e\u0442\u043e\u043a \u0432 Sass, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u044e\u0442 \u0436\u0438\u0437\u043d\u044c \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0446\u0432\u0435\u0442\u0430\u043c\u0438 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u0435\u0440\u0441\u0442\u043a\u0438. \u041c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c 3 \u043f\u043e\u0434\u0445\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043e\u0435\u0434\u0438\u043d\u043e \u043f\u0440\u0438\u043d\u0435\u0441\u0443\u0442 \u043a\u043e\u043c\u0444\u043e\u0440\u0442 \u0432 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0446\u0432\u0435\u0442\u0430\u043c\u0438.<\/p>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435, \u0442\u0430\u043a\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c:<\/p>\n<pre><code>body{   color: color(primary);   background: color(primary, 0.5); }<\/code><\/pre>\n<p>\u0411\u0443\u0434\u0435\u0442 \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u0430 \u0442\u0430\u043a\u043e\u0439:<\/p>\n<pre><code class=\"css\">:root {   --color-pink: #E20071;   --color-pink--rgb: 226, 0, 113; }  body {   color: var(--color-pink);   background: rgba(var(--color-pink--rgb), 0.5); }<\/code><\/pre>\n<p>\u041d\u043e, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u0442\u043e\u043b\u044c\u043a\u043e HEX \u0444\u043e\u0440\u043c\u0430\u0442 \u0446\u0432\u0435\u0442\u0430. \u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435. \u041d\u0438\u043a\u0430\u043a\u0438\u0445 \u0442\u0430\u043d\u0446\u0435\u0432 \u0441 \u0431\u0443\u0431\u043d\u043e\u043c. \u0421\u043c\u043e\u0442\u0440\u0438\u043c:<\/p>\n<h2>\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 CSS \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445<\/h2>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u043b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/developer.mozilla.org\/ru\/docs\/Web\/CSS\/Using_CSS_custom_properties\" rel=\"noopener noreferrer nofollow\">CSS<\/a>, \u0430 \u043d\u0435 <a href=\"https:\/\/sass-scss.ru\/documentation\/sassscript\/peremennie\/\" rel=\"noopener noreferrer nofollow\">Sass<\/a>&nbsp;\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043d\u0430 \u0425\u0430\u0431\u0440\u0435 <a href=\"https:\/\/habr.com\/ru\/post\/456302\/\" rel=\"noopener noreferrer nofollow\">\u0432 \u044d\u0442\u043e\u0439<\/a> \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u0441 \u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u0446\u0432\u0435\u0442\u0430\u043c\u0438.<\/p>\n<pre><code class=\"css\">$colors : (   \"pink\"  : #E20071,   \"blue\"  : #00A3DA,   \"gray\"  : #939394,   \"white\" : #FFFFFF,   \"black\" : #1B1B1B, );<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c CSS \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435,&nbsp;\u043f\u0435\u0440\u0435\u0431\u0440\u0430\u0432 \u0432 \u0446\u0438\u043a\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u043c\u0430\u0441\u0441\u0438\u0432 <em>$colors<\/em> \u0438 \u0437\u0430\u043f\u0438\u0448\u0435\u043c \u0438\u0445 \u0432&nbsp;\u043f\u0441\u0435\u0432\u0434\u043e\u043a\u043b\u0430\u0441\u0441&nbsp;<em>:root<\/em>.<\/p>\n<pre><code class=\"css\">:root{   @each $key, $value in $colors {     --color-#{$key} : #{$value};   } }<\/code><\/pre>\n<p>\u041d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435, \u043f\u043e\u043b\u0443\u0447\u0438\u043c&nbsp; \u044d\u0442\u043e:<\/p>\n<pre><code class=\"css\">:root {   --color-pink: #E20071;   --color-blue: #00A3DA;   --color-gray: #939394;   --color-white: #FFFFFF;   --color-black: #1B1B1B; }<\/code><\/pre>\n<h2>\u041f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c \u0446\u0432\u0435\u0442\u0430<\/h2>\n<p>\u0414\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u0438 \u0432 Sass \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0446\u0432\u0435\u0442 \u0432 <em>RGB<\/em> \u0444\u043e\u0440\u043c\u0430\u0442\u0435, \u043d\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u044b\u0448\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0432 <em>HEX<\/em>. \u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c, \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e:<\/p>\n<pre><code class=\"css\">@function HexToRGB($hex) {   @return red($hex), green($hex), blue($hex); }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435,&nbsp;\u0437\u0430\u043f\u0438\u0448\u0435\u043c \u0446\u0432\u0435\u0442 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e<\/p>\n<pre><code class=\"css\">:root {   --color-pink-rgb: #{HexToRGB(#E20071)}; }<\/code><\/pre>\n<p>\u0418 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <a href=\"https:\/\/developer.mozilla.org\/ru\/docs\/Web\/CSS\/color_value\" rel=\"noopener noreferrer nofollow\">rgba<\/a>, \u0433\u0434\u0435 \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u2014 \u043d\u0443\u0436\u043d\u044b\u0439 \u0446\u0432\u0435\u0442, \u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u2014 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 \u043e\u0442 0 (\u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u0439) \u0434\u043e 1 (\u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043d\u0435\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u0439):<\/p>\n<pre><code class=\"css\">body{   background: rgba(var(--color-pink-rgb), 0.5); } <\/code><\/pre>\n<h2>\u0421\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u043d\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c CSS \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439<\/h2>\n<p>\u0414\u043b\u044f \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u043d\u043e\u0433\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f CSS \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e&nbsp;<em>color<\/em>.<\/p>\n<pre><code class=\"css\">@function color($name) {   @return var(--color-#{unquote($name)}); }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043f\u0438\u0441\u044c:<\/p>\n<pre><code class=\"css\">body{   background: color(pink); }<\/code><\/pre>\n<p>\u0420\u0430\u0432\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u0430 \u0442\u0430\u043a\u043e\u0439:<\/p>\n<pre><code class=\"css\">body{   background: var(--color-pink); }<\/code><\/pre>\n<h2>\u041f\u0440\u043e\u0441\u0442\u0430\u044f \u043c\u0430\u0433\u0438\u044f<\/h2>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043a\u0430\u0436\u0443 \u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f 3 \u044d\u0442\u0438\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u0430, \u043c\u043e\u0436\u043d\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0446\u0432\u0435\u0442\u0430\u043c\u0438 (CSS \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438) \u0442\u0430\u043a, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043c\u0430\u0441\u0441\u0438\u0432 \u043a\u0430\u043a \u0442\u0435\u043c\u0443:<\/p>\n<pre><code class=\"css\">body{   color: color(primary);   background: color(primary, 0.5); }<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0441\u0430\u043c \u043a\u043e\u0434:<\/p>\n<pre><code class=\"css\">$colors_theme : (   \"primary\"   : \"pink\",   \"secondary\" : \"blue\" );  $colors : (   \"pink\"  : #E20071,   \"blue\"  : #00A3DA,   \"gray\"  : #939394,   \"white\" : #FFFFFF,   \"black\" : #1B1B1B, );  @function HexToRGB($hex) {   @return red($hex), green($hex), blue($hex); }  @function color($name, $opacity: false) {   @if $opacity {     @return rgba(var(--color-#{unquote($name)}--rgb), $opacity);   } @else {     @return var(--color-#{unquote($name)});   } }  :root{   @if $colors {     @if $colors_theme {       @each $key, $value in $colors_theme {         --color-#{$key} : var(--color-#{$value});         --color-#{$key}--rgb : var(--color-#{$value}--rgb);       }     }      @each $key, $value in $colors {       --color-#{$key} : #{$value};       --color-#{$key}--rgb : #{HexToRGB($value)};     }   } }<\/code><\/pre>\n<p>\u041d\u0443 \u0432\u043e\u0442 \u0438 \u0432\u0441\u0435, \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u044b\u0432\u043e\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442\u0441\u044f \u0438 \u0443\u0441\u043a\u043e\u0440\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u0446\u0432\u0435\u0442\u0430\u043c\u0438.<\/p>\n<p>\u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0430\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0438\u043c\u0435\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0446\u0432\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 HEX \u0444\u043e\u0440\u043c\u0430\u0442\u0435, \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0446\u0432\u0435\u0442\u043e\u0432\u0443\u044e \u043f\u0430\u043b\u0438\u0442\u0440\u0443 \u0441\u0430\u0439\u0442\u0430. \u0418 \u043d\u0435 \u043f\u0440\u0438\u0431\u0435\u0433\u043d\u0443\u0442\u044c \u043a \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c <strong>\u043a\u043e\u0434\u043e\u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f\u043c<\/strong>.<\/p>\n<\/p>\n<p>\u041f\u0440\u043e\u0448\u0443 \u0441\u0442\u0440\u043e\u0433\u043e \u043d\u0435 \u0441\u0443\u0434\u0438\u0442\u044c \u2014 \u044d\u0442\u043e \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0430 \u0425\u0430\u0431\u0440\u0435.<\/p>\n<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/533084\/\"> https:\/\/habr.com\/ru\/post\/533084\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u0430 \u043e\u0431\u0437\u043e\u0440\u0443 \u043c\u043e\u0438\u0445 \u043d\u0430\u0440\u0430\u0431\u043e\u0442\u043e\u043a \u0432 Sass, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u044e\u0442 \u0436\u0438\u0437\u043d\u044c \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0446\u0432\u0435\u0442\u0430\u043c\u0438 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u0435\u0440\u0441\u0442\u043a\u0438. \u041c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c 3 \u043f\u043e\u0434\u0445\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043e\u0435\u0434\u0438\u043d\u043e \u043f\u0440\u0438\u043d\u0435\u0441\u0443\u0442 \u043a\u043e\u043c\u0444\u043e\u0440\u0442 \u0432 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0446\u0432\u0435\u0442\u0430\u043c\u0438.<\/p>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435, \u0442\u0430\u043a\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c:<\/p>\n<pre><code>body{   color: color(primary);   background: color(primary, 0.5); }<\/code><\/pre>\n<p>\u0411\u0443\u0434\u0435\u0442 \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u0430 \u0442\u0430\u043a\u043e\u0439:<\/p>\n<pre><code class=\"css\">:root {   --color-pink: #E20071;   --color-pink--rgb: 226, 0, 113; }  body {   color: var(--color-pink);   background: rgba(var(--color-pink--rgb), 0.5); }<\/code><\/pre>\n<p>\u041d\u043e, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u0442\u043e\u043b\u044c\u043a\u043e HEX \u0444\u043e\u0440\u043c\u0430\u0442 \u0446\u0432\u0435\u0442\u0430. \u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435. \u041d\u0438\u043a\u0430\u043a\u0438\u0445 \u0442\u0430\u043d\u0446\u0435\u0432 \u0441 \u0431\u0443\u0431\u043d\u043e\u043c. \u0421\u043c\u043e\u0442\u0440\u0438\u043c:<\/p>\n<h2>\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 CSS \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445<\/h2>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u043b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/developer.mozilla.org\/ru\/docs\/Web\/CSS\/Using_CSS_custom_properties\" rel=\"noopener noreferrer nofollow\">CSS<\/a>, \u0430 \u043d\u0435 <a href=\"https:\/\/sass-scss.ru\/documentation\/sassscript\/peremennie\/\" rel=\"noopener noreferrer nofollow\">Sass<\/a>&nbsp;\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043d\u0430 \u0425\u0430\u0431\u0440\u0435 <a href=\"https:\/\/habr.com\/ru\/post\/456302\/\" rel=\"noopener noreferrer nofollow\">\u0432 \u044d\u0442\u043e\u0439<\/a> \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u0441 \u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u0446\u0432\u0435\u0442\u0430\u043c\u0438.<\/p>\n<pre><code class=\"css\">$colors : (   \"pink\"  : #E20071,   \"blue\"  : #00A3DA,   \"gray\"  : #939394,   \"white\" : #FFFFFF,   \"black\" : #1B1B1B, );<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c CSS \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435,&nbsp;\u043f\u0435\u0440\u0435\u0431\u0440\u0430\u0432 \u0432 \u0446\u0438\u043a\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u043c\u0430\u0441\u0441\u0438\u0432 <em>$colors<\/em> \u0438 \u0437\u0430\u043f\u0438\u0448\u0435\u043c \u0438\u0445 \u0432&nbsp;\u043f\u0441\u0435\u0432\u0434\u043e\u043a\u043b\u0430\u0441\u0441&nbsp;<em>:root<\/em>.<\/p>\n<pre><code class=\"css\">:root{   @each $key, $value in $colors {     --color-#{$key} : #{$value};   } }<\/code><\/pre>\n<p>\u041d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435, \u043f\u043e\u043b\u0443\u0447\u0438\u043c&nbsp; \u044d\u0442\u043e:<\/p>\n<pre><code class=\"css\">:root {   --color-pink: #E20071;   --color-blue: #00A3DA;   --color-gray: #939394;   --color-white: #FFFFFF;   --color-black: #1B1B1B; }<\/code><\/pre>\n<h2>\u041f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c \u0446\u0432\u0435\u0442\u0430<\/h2>\n<p>\u0414\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u0438 \u0432 Sass \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0446\u0432\u0435\u0442 \u0432 <em>RGB<\/em> \u0444\u043e\u0440\u043c\u0430\u0442\u0435, \u043d\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u044b\u0448\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0432 <em>HEX<\/em>. \u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c, \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e:<\/p>\n<pre><code class=\"css\">@function HexToRGB($hex) {   @return red($hex), green($hex), blue($hex); }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435,&nbsp;\u0437\u0430\u043f\u0438\u0448\u0435\u043c \u0446\u0432\u0435\u0442 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e<\/p>\n<pre><code class=\"css\">:root {   --color-pink-rgb: #{HexToRGB(#E20071)}; }<\/code><\/pre>\n<p>\u0418 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <a href=\"https:\/\/developer.mozilla.org\/ru\/docs\/Web\/CSS\/color_value\" rel=\"noopener noreferrer nofollow\">rgba<\/a>, \u0433\u0434\u0435 \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u2014 \u043d\u0443\u0436\u043d\u044b\u0439 \u0446\u0432\u0435\u0442, \u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u2014 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 \u043e\u0442 0 (\u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u0439) \u0434\u043e 1 (\u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043d\u0435\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u0439):<\/p>\n<pre><code class=\"css\">body{   background: rgba(var(--color-pink-rgb), 0.5); } <\/code><\/pre>\n<h2>\u0421\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u043d\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c CSS \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439<\/h2>\n<p>\u0414\u043b\u044f \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u043d\u043e\u0433\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f CSS \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e&nbsp;<em>color<\/em>.<\/p>\n<pre><code class=\"css\">@function color($name) {   @return var(--color-#{unquote($name)}); }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043f\u0438\u0441\u044c:<\/p>\n<pre><code class=\"css\">body{   background: color(pink); }<\/code><\/pre>\n<p>\u0420\u0430\u0432\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u0430 \u0442\u0430\u043a\u043e\u0439:<\/p>\n<pre><code class=\"css\">body{   background: var(--color-pink); }<\/code><\/pre>\n<h2>\u041f\u0440\u043e\u0441\u0442\u0430\u044f \u043c\u0430\u0433\u0438\u044f<\/h2>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043a\u0430\u0436\u0443 \u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f 3 \u044d\u0442\u0438\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u0430, \u043c\u043e\u0436\u043d\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0446\u0432\u0435\u0442\u0430\u043c\u0438 (CSS \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438) \u0442\u0430\u043a, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043c\u0430\u0441\u0441\u0438\u0432 \u043a\u0430\u043a \u0442\u0435\u043c\u0443:<\/p>\n<pre><code class=\"css\">body{   color: color(primary);   background: color(primary, 0.5); }<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0441\u0430\u043c \u043a\u043e\u0434:<\/p>\n<pre><code class=\"css\">$colors_theme : (   \"primary\"   : \"pink\",   \"secondary\" : \"blue\" );  $colors : (   \"pink\"  : #E20071,   \"blue\"  : #00A3DA,   \"gray\"  : #939394,   \"white\" : #FFFFFF,   \"black\" : #1B1B1B, );  @function HexToRGB($hex) {   @return red($hex), green($hex), blue($hex); }  @function color($name, $opacity: false) {   @if $opacity {     @return rgba(var(--color-#{unquote($name)}--rgb), $opacity);   } @else {     @return var(--color-#{unquote($name)});   } }  :root{   @if $colors {     @if $colors_theme {       @each $key, $value in $colors_theme {         --color-#{$key} : var(--color-#{$value});         --color-#{$key}--rgb : var(--color-#{$value}--rgb);       }     }      @each $key, $value in $colors {       --color-#{$key} : #{$value};       --color-#{$key}--rgb : #{HexToRGB($value)};     }   } }<\/code><\/pre>\n<p>\u041d\u0443 \u0432\u043e\u0442 \u0438 \u0432\u0441\u0435, \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u044b\u0432\u043e\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442\u0441\u044f \u0438 \u0443\u0441\u043a\u043e\u0440\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u0446\u0432\u0435\u0442\u0430\u043c\u0438.<\/p>\n<p>\u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0430\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0438\u043c\u0435\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0446\u0432\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 HEX \u0444\u043e\u0440\u043c\u0430\u0442\u0435, \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0446\u0432\u0435\u0442\u043e\u0432\u0443\u044e \u043f\u0430\u043b\u0438\u0442\u0440\u0443 \u0441\u0430\u0439\u0442\u0430. \u0418 \u043d\u0435 \u043f\u0440\u0438\u0431\u0435\u0433\u043d\u0443\u0442\u044c \u043a \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c <strong>\u043a\u043e\u0434\u043e\u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f\u043c<\/strong>.<\/p>\n<\/p>\n<p>\u041f\u0440\u043e\u0448\u0443 \u0441\u0442\u0440\u043e\u0433\u043e \u043d\u0435 \u0441\u0443\u0434\u0438\u0442\u044c \u2014 \u044d\u0442\u043e \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0430 \u0425\u0430\u0431\u0440\u0435.<\/p>\n<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/533084\/\"> https:\/\/habr.com\/ru\/post\/533084\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-314874","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/314874","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=314874"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/314874\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=314874"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=314874"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=314874"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}