Skip to content

Instantly share code, notes, and snippets.

@mindon
Last active November 29, 2024 07:51
Show Gist options
  • Select an option

  • Save mindon/c5ff5dfbeb7cced310ddb346e2ba2d7a to your computer and use it in GitHub Desktop.

Select an option

Save mindon/c5ff5dfbeb7cced310ddb346e2ba2d7a to your computer and use it in GitHub Desktop.
Chinese Tai-Chi Diagram Pure CSS Style
.yinyang {
--size: 360px;
--dot: 60px;
--yin: #222;
--yang: #c30;
--duration: 8s;
width:var(--size);
height:var(--size);
position: relative;
overflow: hidden;
transform: rotate(90deg);
animation-name: loop;
animation-duration: var(--duration);
animation-iteration-count: infinite;
animation-timing-function: linear;
}
.yin, .yang {
width: 50%;
height: 100%;
position: absolute;
}
.yin {
--front: var(--yin);
--back: var(--yang);
background-color: var(--front);
border-radius: calc(var(--size)/2) 0 0 calc(var(--size)/2);
}
.yin, .yin::before,.yin::after,
.yang, .yang::before,.yang::after {
animation-duration: var(--duration);
animation-iteration-count: infinite;
animation-timing-function: ease-in;
}
.yin::after,
.yang::after {
animation-timing-function: ease-out;
}
.yin, .yin::before, .yang::after {
animation-name: yin;
}
.yang, .yang::before, .yin::after {
animation-name: yang;
}
.yang {
--front: var(--yang);
--back: var(--yin);
right: 0;
background-color: var(--front);
border-radius: 0 calc(var(--size)/2) calc(var(--size)/2) 0;
}
.yin::before,
.yang::before {
content: ' ';
width: 100%;
height: 50%;
background-color: var(--front);
border-radius: 50%;
position: absolute;
z-index: 9;
}
.yin::before {
bottom: 0;
left: 50%;
}
.yang::before {
top: 0;
right: 50%;
}
.yin::after,
.yang::after {
content: '';
width: var(--dot);
height: var(--dot);
background-color: var(--back);
border-radius: calc(var(--dot)/2);
z-index: 12;
position: absolute;
--x: calc(var(--dot) / -2);
--y: calc(25% - var(--dot) / 2);
}
.yin::after {
right: var(--x);
bottom: var(--y);
}
.yang::after {
left: var(--x);
top: var(--y);
}
@keyframes loop {
from { transform: rotate(90deg); }
to { transform: rotate(-270deg); }
}
@keyframes yin {
from { background-color: var(--yin); }
50% { background-color: var(--yang); }
to { background-color: var(--yin); }
}
@keyframes yang {
from { background-color: var(--yang); }
50% { background-color: var(--yin); }
to { background-color: var(--yang); }
}
/**
<!--https://mindon.dev -->
<div class="yinyang">
<div class="yin"></div><div class="yang"></div>
</div>
**/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment