首页 > 数据库技术 > 详细

[SCSS] Access Theme Color Values With Sass

时间:2020-05-19 09:27:35      阅读:69      评论:0      收藏:0      [点我收藏+]

Manage the color palette used in your stylesheets by creating a map of variables and a function to access the values by key. This allows you to update the colors in one location to re-theme your application and eliminate manual find and replace.

 

$color-primary: indigo;
$color-secondary: blue;
$color-support: deeppink;

$theme-colors: (
  primary: $color-primary,
  secondary: $color-secondary,
  support: $color-support
);

@function theme-color($key) {
  @return map-get($theme-colors, $key);
}


h1 {
  color: theme-color(primary);
}

a {
  background-color: theme-color(support);
  color: #fff;
  border-radius: 8px;
  text-decoration: none;
  padding: 0.25em 0.75em;

  &:hover {
    background-color: scale-color(theme-color(support), $lightness: -30%);
  }
}

 

[SCSS] Access Theme Color Values With Sass

原文:https://www.cnblogs.com/Answer1215/p/12914353.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!