[SCSS] Use Standard Built-in SCSS Functions for Common Operations

We can use javascript for color and opacity variations, math, list and map logic or to see if something exists. SCSS includes functions for a wide range of common use cases for logic in our styles. In this lesson we look at some of the more useful color functions to improve development velocity, readability, and simplify the code. Be sure to checkout all the SCSS functions: http://sass-lang.com/documentation/Sass/Script/Functions.html

$base: #24ea12;
$lighten_base: lighten($base, 25%);
$darken_base: darken($base, 25%);

$clb: complement($base);
$cllb: complement($lighten_base);
$cldb: complement($darken_base);

$light-color: scale_color($base, $alpha: -50%);
$dark-color: scale_color($base, $saturation: -35%);

.base {
  background-color: $base;
  color: $clb;
}

.lighten_base {
  background-color: $lighten_base;
  color: $cllb;
}

.darken_base {
  background-color: $darken_base;
  color: $cldb;
}

.linear-gradient {
  background-image: linear-gradient($clb, $cllb, $cldb);
  color: mix($base, yellow, 25%);
}

.hover {
  background-image: linear-gradient($base, $lighten_base, $darken_base);
  color: mix($base, yellow, 25%);
  &:hover {
    color: transparentize(mix($base, yellow, 25%), .5); // based on given color, add 0.5 opacity
  }
}

.darken-color {
  color: $dark-color;
}

.lighten-color {
  color: $light-color;
}

.container {
  display: grid;
  grid-gap: 10px;
  grid-template-columns: 1fr 1fr 1fr;
  counter-reset: box;
  height: 100vh;
}

.box:before {
  counter-increment: box;
  font-size: 3em;
  content: counter(box);
}

.box {
  display: flex;
  justify-content: center;
  align-content: center;
  align-items: center;
}

Github

时间: 2024-10-14 09:43:25

[SCSS] Use Standard Built-in SCSS Functions for Common Operations的相关文章

[SCSS] Reuse Styles with the SCSS @mixin Directive

Copy/pasting the same code is redundant and updating copy/pasted code slows development velocity. Mixins are reusable chunks of code that are included, similar to calling a function, instead of copy/pasted. Mixins have some nice features:- Arguments

Data Types

原地址: Home / Database / Oracle Database Online Documentation 11g Release 2 (11.2) / Database Administration Data Types Each value manipulated by Oracle Database has a data type. The data type of a value associates a fixed set of properties with the va

初识scss(1)

最近在看sass,先总结了一点点,为了以后自己来看不用去翻文档:如果那里不正确欢迎指正! 什么是 Sass? Sass 官网上是这样描述 Sass 的: Sass 是一门高于 CSS 的元语言,它能用来清晰地.结构化地描述文件样式,有着比普通 CSS 更加强大的功能. Sass 能够提供更简洁.更优雅的语法,同时提供多种功能来创建可维护和管理的样式表. Sass 和 SCSS 有什么区别? Sass 和 SCSS 其实是同一种东西,我们平时都称之为 Sass,两者之间不同之处有以下两点: 文件扩

less以及SCSS基础语法

less 1.注释: //这种注释不能够编译到CSS 文件中 /*这种注释 能够编译到CSS 文件中*/ 2.less 的基础语法 (1).声明变量: @变量名 : 变量值 使用变量: @变量名 >>>变量使用的基本原则: 多次频繁出现的值,后期需要统一修改的值,牵扯到数值运算的值,推荐使用变量 >>>less 中的变量类型 ①数值类: 不带单位的 123, 带单位的 1px ②字符串类型: 不带引号的 red #FF0000 带引号的"hahhaha&quo

webstorm配置scss自动编译路径

webstorm支持sass的同步编译,也就是即写即编译,并且可以指定编译后的css的目录. 本文使用的webstorm为8.0版本 点击左上角的File→Settings→File Watchers 在弹窗的窗口的右上角点击绿色的 ‘+’ 号,然后选择scss ------------------------------------------------------------------------------- Arguments: 可以配置编译后的文件的输出路径,我这里写的是: --n

[SCSS] Organize SCSS into Multiple Files with Partials

Tired of dealing with monolithic CSS files? Are requests for multiple CSS files hurting your performance? In this lesson we learn how to separate our styles with SCSS partials, and how SCSS imports compile to one file so there's only one request. Thi

编译sass,遇到报错error style.scss (Line 3: Invalid GBK character "\xE5")

今天学习sass,写了一行中文注释,结果却遇到了报错: 1 cmd.exe /D /C call C:/Ruby23-x64/bin/scss.bat --no-cache --update style.scss:style.css 2 error style.scss (Line 3: Invalid GBK character "\xE5") 3 4 Process finished with exit code 1 以前在公司使用的mac没用遇到这种问题,当使用windows 7

sass / scss

Sass 有两种语法规则(syntaxes),目前新的语法规则(从 Sass 3开始)被称为 "SCSS"( 时髦的css(Sassy CSS)),它是css3语法的的拓展级,就是说每一个语法正确的CSS3文件也是合法的SCSS文件,SCSS文件使用.scss作为拓展名.第二种语法别成为缩进语法(或者 Sass),它受到了Haml的简洁精炼的启发,它是为了人们可以用和css相近的但是更精简的方式来书写css而诞生的.它没有括号,分号,它使用 行缩进 的方式来指定css 块,虽然sass

webpack单独构建scss文件与.vue组件里构建scss的一个坑

在入口main.js里构建scss是通过引入模块的方式 import './assets/_reset.scss'; import './assets/_flex.scss'; import './assets/_functions.scss'; 在.vue组件里是单独构建的 <style lang="scss" scoped> img { width: rem(300px); } #product, .gallery, .detail { width: rem(750px