<link href='//fonts.googleapis.com/css?family=Signika+Negative:300,400' rel='stylesheet' type='text/css'>
<div class="wrapper">
<h2>Apply same --myColor variable to multiple css rules.</h2>
<p>Tweening the <strong> --myColor</strong> variable will update multiple elements.</p>
<div class="cool">this is cool </div>
</div>
body {
margin:20px;
}
html {
--myColor: #00bae2;
}
h2 {
font-size:20px;
}
.wrapper {
border: 3px solid var(--myColor);
border-radius: 10px;
margin-right:10px;
padding: 1rem;
}
h2, strong {
color:var(--myColor);
}
.cool {
display:inline-block;
padding: 0.5rem 1rem;
color:white;
border-radius:99px;
background-color:var(--myColor);
}
gsap.to("html", {"--myColor":"#0ae448", yoyo:true, repeat:20, duration: 1});