Skip to content

Instantly share code, notes, and snippets.

@daanta-real
Last active November 24, 2022 05:34
Show Gist options
  • Save daanta-real/7d18a4c8357d5dc6e8bf48f3b17a0009 to your computer and use it in GitHub Desktop.
Save daanta-real/7d18a4c8357d5dc6e8bf48f3b17a0009 to your computer and use it in GitHub Desktop.
A toast appears and immediately fadeout, and finally removed
<style>
@keyframes fadeout {
from { opacity:1; }
to { opacity:0; }
}
.toast {
position:fixed; left:0; bottom:0; padding:10px;
font-size:50px; color:red; font-weight:900;
animation: fadeout 1s ease-in forwards;
}
</style>
<script>
function showToast() {
const el = Object.assign(document.createElement("div"), {
classList: "toast",
textContent: "토스트"
});
document.body.append(el);
setTimeout(() => el.remove(), 1000);
}
showToast();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment