Created
February 18, 2023 22:25
-
-
Save yarliganfatih/302c65932ee9102d621c3b1da54f6bfe to your computer and use it in GitHub Desktop.
function structure with pure CSS
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
<style> | |
/* define a function */ | |
.myFunction { | |
border: 3px solid rgba(var(--baseColorRGB)); | |
background-color: rgba(var(--baseColorRGB), 0.2); | |
} | |
/* Global Variables (Default Parameters) */ | |
:root { | |
--baseColorRGB: 255, 0, 0; | |
} | |
.parameterPackage{ | |
--baseColorRGB: 0, 255, 0; | |
} | |
</style> | |
<!-- Call the function without any parameter (meanwhile default parameters are used) --> | |
<div | |
class="myFunction" | |
> | |
Output | |
</div> | |
<!-- Call the function with the parameter package --> | |
<div | |
class="parameterPackage myFunction" | |
> | |
Output | |
</div> | |
<!-- Call the function with a parameter --> | |
<div | |
class="myFunction" | |
style="--baseColorRGB: 0, 0, 255" | |
> | |
Output | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://codepen.io/yarliganfatih/pen/gOdaRRg