¿©·¯ µµÇüÀÌ ¼ø¼¿¡ µû¶ó Å©±â, ȸÀü, »ö»ó, ¸ð¾çÀÌ º¯ÈÇÏ´Â CSS ¾Ö´Ï¸ÞÀÌ¼Ç ¿¹Á¦ÀÔ´Ï´Ù.
sibling-index()¸¦ Ȱ¿ëÇØ ¿ä¼Òº°·Î ½Ã°£Â÷¸¦ ÁÖ¾î ÀÚ¿¬½º·¯¿î È帧À» Ç¥ÇöÇÕ´Ï´Ù.
¹Ýº¹µÇ´Â µµÇüÀ̳ª ±×¸®µå ÇüÅÂÀÇ ¸ð¼Ç È¿°ú¸¦ ±¸ÇöÇÒ ¶§ Âü°íÇϱâ ÁÁ½À´Ï´Ù.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="./style.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pen</title>
</head>
<body>
<div class="grid" lang="njk">
{% for i in range(0, 64) %}
<div></div>
{% endfor %}
</div>
<div class="warning">
⚠️ Sorry, your browser doesn't support sibling-index()
</div>
</body>
</html>
html {
height: 100%;
background: #fcfcfc;
}
body {
display: grid;
grid-template-columns: minmax(0, 1fr);
height: 100%;
place-content: center;
margin: 0;
}
.grid {
display: grid;
grid-template-columns: repeat(8, minmax(0, 1fr));
width: 100%;
max-width: min(calc(100vmin - 2rem), 40rem);
margin-inline: auto;
div {
width: 100%;
aspect-ratio: 1;
background-color: #599cb7;
animation: spin 3s cubic-bezier(.79,.14,.15,.86) infinite;
animation-delay: calc(sibling-index() * 12ms);
}
}
@keyframes spin {
0% {
transform: rotate(0deg);
border-radius: 0;
}
35% {
transform: rotate(360deg) scale(calc(sibling-index() / sibling-count() / 1.4));
background-color: #ffd100;
border-radius: 100px;
}
70%, 100% {
border-radius: 0;
transform: rotate(0deg);
}
}
/* The below is just to warn users who don't have browser support */
.warning {
background: red;
padding: 1rem;
color: white;
text-transform: uppercase;
text-align: center;
font-family: system-ui, sans-serif;
position: fixed;
top: 0;
left: 0;
right: 0;
display: none;
}
@supports not (transform: scale(calc(sibling-index() / sibling-count()))) {
.warning {
display: block;
}
}