greeper 27520274

/* You found the CSS of the answer to "Animate <details> tag". */
/* Heads up! This is ONLY CSS */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap");
*,
*:after,
*:before {
  box-sizing: border-box;
}

body {
  font-family: "Inter", sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  background-color: #f4f5f7;
  padding-top: 10vh;
  padding-bottom: 10vh;
}

strong {
  font-weight: 600;
}

article {
  width: 90%;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  font-size: 1.125rem;
  padding: 2rem;
  background-color: #fff;
  border-radius: 10px;
  box-shadow: 0 15px 20px -10px rgba(0, 0, 0, 0.1);
}
article > * + * {
  margin-top: 1em;
}
article:is(h1, h2, h3) + * {
  margin-top: 0.5em;
}
article h1 {
  font-weight: 900;
  font-size: 2rem;
  line-height: 1.125;
}
article code {
  background-color: #eee;
  font-weight: 600;
  font-family: monospace;
}
article ol {
  counter-reset: sickstuff;
}
article ol li {
  position: relative;
  padding-left: 32px;
  counter-increment: sickstuff;
}
article ol li + li {
  margin-top: 0.5em;
}
article ol li:before {
  content: counter(sickstuff);
  width: 24px;
  height: 24px;
  position: absolute;
  left: 0;
  top: calc((1.125rem * 1.5) - 24px);
  font-size: 0.75em;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: #185adb;
  color: #fff;
  font-weight: 600;
}

details {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  margin-top: 2rem;
  color: #6b7280;
  display: flex;
  flex-direction: column;
}
details div {
  background-color: #fff;
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.15);
  padding: 1.25rem;
  border-radius: 8px;
  position: absolute;
  max-height: calc(100vh - 100px);
  width: 400px;
  max-width: calc(100vw - 2rem);
  bottom: calc(100% + 1rem);
  right: 0;
  overflow: auto;
  transform-origin: 100% 100%;
  color: #000;
}
details div::-webkit-scrollbar {
  width: 15px;
  background-color: #fff;
}
details div::-webkit-scrollbar-thumb {
  width: 5px;
  border-radius: 99em;
  background-color: #95a3b9;
  border: 5px solid #fff;
}
details div > * + * {
  margin-top: 0.75em;
}
details div p > code {
  font-size: 1rem;
  font-family: monospace;
}
details div pre {
  white-space: pre-line;
  border: 1px solid #95a3b9;
  border-radius: 6px;
  font-family: monospace;
  padding: 0.75em;
  font-size: 0.875rem;
  color: #000;
}
details[open] div {
  -webkit-animation: scale 0.25s ease;
          animation: scale 0.25s ease;
}

summary {
  display: inline-flex;
  margin-left: auto;
  margin-right: auto;
  justify-content: center;
  align-items: center;
  font-weight: 600;
  padding: 0.75em 3em 0.75em 1.25em;
  border-radius: 99em;
  color: #fff;
  background-color: #185adb;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  list-style: none;
  text-align: center;
  cursor: pointer;
  transition: 0.15s ease;
  position: relative;
}
summary::-webkit-details-marker {
  display: none;
}
summary:hover, summary:focus {
  background-color: #1348af;
}
summary svg {
  position: absolute;
  right: 1.25em;
  top: 50%;
  transform: translateY(-50%);
  width: 1.5em;
  height: 1.5em;
}

@-webkit-keyframes scale {
  0% {
    transform: scale(0);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes scale {
  0% {
    transform: scale(0);
  }
  100% {
    transform: scale(1);
  }
}

Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source