Skip to content

Commit aa1eb0f

Browse files
committed
Add Lighten And Darken With SCSS as a css til
1 parent c6bb8df commit aa1eb0f

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ variety of languages and technologies. These are things that don't really
77
warrant a full blog post. These are mostly things I learn by pairing with
88
smart people at [Hashrocket](http://hashrocket.com/).
99

10-
_377 TILs and counting..._
10+
_378 TILs and counting..._
1111

1212
---
1313

1414
### Categories
1515

1616
* [Chrome](#chrome)
1717
* [Clojure](#clojure)
18+
* [CSS](#css)
1819
* [Devops](#devops)
1920
* [Elixir](#elixir)
2021
* [Git](#git)
@@ -58,6 +59,10 @@ _377 TILs and counting..._
5859
- [Type of Anything](clojure/type-of-anything.md)
5960
- [When Overflow Is Desired](clojure/when-overflow-is-desired.md)
6061

62+
### CSS
63+
64+
- [Lighten And Darken With SCSS](css/lighten-and-darken-with-scss.md)
65+
6166
### Devops
6267

6368
- [Aliasing An Ansible Host](devops/aliasing-an-ansible-host.md)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Lighten And Darken With SCSS
2+
3+
With SCSS, a color can be lightened or darkened by a certain percentage
4+
using the
5+
[`lighten`](http://sass-lang.com/documentation/Sass/Script/Functions.html#lighten-instance_method)
6+
and
7+
[`darken`](http://sass-lang.com/documentation/Sass/Script/Functions.html#darken-instance_method)
8+
functions, respectively.
9+
10+
For instance, given the following HTML
11+
12+
```html
13+
<div class='one'></div>
14+
<div class='two'></div>
15+
<div class='three'></div>
16+
```
17+
18+
I can style `div.two` with the original color and then style `div.one` with
19+
a lightened version and `div.three` with a darkened version.
20+
21+
```scss
22+
$box-color: #0074d9;
23+
24+
.two {
25+
background: $box-color;
26+
}
27+
.one {
28+
background: lighten($box-color, 20%);
29+
}
30+
.three {
31+
background: darken($box-color, 20%);
32+
}
33+
```
34+
35+
The result looks something like this:
36+
37+
![](http://i.imgur.com/SaeTL8H.png)

0 commit comments

Comments
 (0)