1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-04 23:58:01 +00:00

Add Lighten And Darken With CSS Brightness Filter as a css til

This commit is contained in:
jbranchaud
2017-09-08 15:37:34 -05:00
parent 86a9885dbe
commit 3137901d5e
2 changed files with 33 additions and 1 deletions

View File

@@ -0,0 +1,31 @@
# Lighten And Darken With CSS Brightness Filter
CSS has a `filter` property that can be used with a variety of filter
functions. One of them is the `brightness()` filter. By feeding a percentage
less than `100%` to `brightness()`, the target element will be made darker.
Inversely, feeding a percentage greater than `100%` to `brightness()` will
make the element brighter.
```css
.brighter-span {
filter: brightness(150%);
}
.darker-span {
filter: brightness(50%);
}
```
<p data-height="171" data-theme-id="0" data-slug-hash="OjKJpa"
data-default-tab="result" data-user="jbranchaud" data-embed-version="2"
data-pen-title="OjKJpa" class="codepen">See the Pen <a
href="https://codepen.io/jbranchaud/pen/OjKJpa/">OjKJpa</a> by Josh
Branchaud (<a href="https://codepen.io/jbranchaud">@jbranchaud</a>) on <a
href="https://codepen.io">CodePen</a>.</p>
<script async
src="https://production-assets.codepen.io/assets/embed/ei.js"></script>
See this [CSS Tricks Article on the `filter`
property](https://css-tricks.com/almanac/properties/f/filter/) for more
details. Check out the browser support story
[here](http://caniuse.com/#feat=css-filters).