PLUGINS
MODULES
PolyDev
BLOG
Dự án
Ý tưởng & tính năng
Phần Mềm
POD
Tài Liệu Hướng Dẫn
API’s
Tiếng Việt
English
Plugins
PolyDev
Sample code hiệu ứng fadeIn từng ký tự
18/09/2024
/
thankzone
HTML
CSS
JS
RESULT
HTML
Dracula
Yonce
Monokai
Material
Darcula
Solarized
Eclipse
Midnight
Ambiance
Cobalt
Neo
Twilight
XQ Dark
XQ Light
Zenburn
CSS
Dracula
Yonce
Monokai
Material
Darcula
Solarized
Eclipse
Midnight
Ambiance
Cobalt
Neo
Twilight
XQ Dark
XQ Light
Zenburn
body { font-family: 'Arial', sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; background-color: #333; color: #fff; } #text-container { font-size: 2em; letter-spacing: 0.1em; white-space: break-spaces; word-wrap: break-word; } .fade-in-char { opacity: 0; display: inline-block; transition: opacity 0.5s ease; } .fade-in-char.visible { opacity: 1; }
JavaScript
Dracula
Yonce
Monokai
Material
Darcula
Solarized
Eclipse
Midnight
Ambiance
Cobalt
Neo
Twilight
XQ Dark
XQ Light
Zenburn
const text1 = "PolyXGO welcomes you!"; const text2 = "This is the typing effect with fadeIn!"; const textContainer = document.getElementById('text-container'); function createFadeInEffect(text, container, callback) { container.innerHTML = ''; // Clear the container text.split('').forEach((char, index) => { const span = document.createElement('span'); span.classList.add('fade-in-char'); span.textContent = char; container.appendChild(span); // Set a timeout to gradually show each character setTimeout(() => { span.classList.add('visible'); // Call the callback after the last character fades in if (index === text.length - 1 && callback) { setTimeout(callback, 500); // Delay before starting next text } }, index * 100); // Delay increases for each character }); } // Apply the fade-in effect when the page loads /*window.onload = () => { createFadeInEffect(text1, textContainer, () => { createFadeInEffect(text2, textContainer); }); };*/ setTimeout(() => { // Apply the fade-in effect for both texts, one after the other createFadeInEffect(text1, textContainer, () => { createFadeInEffect(text2, textContainer); }); }, 100);
Preview: Sample code hiệu ứng fadeIn từng ký tự
By me a coffee
<body>
@polyxgo
PolyXGO