Skip to content

Instantly share code, notes, and snippets.

@yarliganfatih
Created February 18, 2023 22:25
Show Gist options
  • Save yarliganfatih/302c65932ee9102d621c3b1da54f6bfe to your computer and use it in GitHub Desktop.
Save yarliganfatih/302c65932ee9102d621c3b1da54f6bfe to your computer and use it in GitHub Desktop.
function structure with pure CSS
<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>
@yarliganfatih
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment