Last active
November 24, 2022 05:34
-
-
Save daanta-real/7d18a4c8357d5dc6e8bf48f3b17a0009 to your computer and use it in GitHub Desktop.
A toast appears and immediately fadeout, and finally removed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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