Last active
September 1, 2018 20:09
-
-
Save jobthomas/78a0526108a9ff2339c41aebee6bb7a8 to your computer and use it in GitHub Desktop.
Gradient change for form elements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$color: #804A69; | |
/*------- | |
Goal: The main color gets lighten by a small percentage each time the nth-of-type increase | |
-------*/ | |
form { // to limit to forms only | |
$n: 15; // to make sure the loop stops | |
@for $i from 0 to $n { // for loop | |
$label: $i/10 * 100% - 10%; // e.g. for nth-of-type(1) $i = 3 -> $label = (3/10 * 100%) - 10% = 20% | |
$input: $i/10 * 100% - 5%; // e.g. for nth-of-type(3) $i = 3 -> $input = (3/10 * 100%) - 5% = 25% | |
div:nth-of-type(#{$i + 1}) { // start loop | |
label { | |
color: lighten($color, $label); // e.g. for nth-of-type(3), color: lighten( #804A69, 20%); | |
} | |
input[type], | |
textarea { | |
border: 2px solid lighten($color, $input); | |
&:focus { | |
background-image: linear-gradient(to bottom right, transparent, transparent, lighten($color, 55%)); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment