Sparkly Spoiler Effect JavaScript HTML CSS

Spread the love

Sparkly Spoiler Effect JavaScript HTML CSS

Hey! If you have wanted to build a Sparkly Spoiler but had no idea where to start, you are in the right place.

What We Are Building

We are building a Sparkly Spoiler text effect. It is cool!

HTML Structure

We use HTML to define.

index.html

<!DOCTYPE html><html lang='en'><head><meta charset='UTF-8'><meta name='viewport' content='width=device-width, initial-scale=1.0'><title>Sparkly Spoiler Effect</title><link rel='stylesheet' href='styles.css'></head><body><div class='spoiler'><span>Spoiler Alert!</span></div><script src='script.js'></script></body></html>

CSS Styling

CSS styles our text.

styles.css

body{margin:0;padding:0;font-family:Arial, Helvetica, sans-serif;}*{box-sizing:border-box;}*{overflow:hidden;}body{background-color:#0f172a;}#container{display:flex;justify-content:center;align-items:center;height:100vh;}.spoiler{position:relative;width:300px;height:200px;background-color:rgba(15,23,42,0.5);border-radius:10px;box-shadow:0 0 10px #08f,0 0 20px #08f,0 0 30px #08f;cursor:pointer;}.spoiler::before{content:'';position:absolute;top:0;left:0;width:100%;height:100%;background-color:inherit;border-radius:inherit;z-index:-1;transform:scaleY(0);transition:transform 0.5s ease-in-out;}.spoiler:hover::before{transform:scaleY(1);}.spoiler span{position:relative;z-index:1;font-size:24px;color:#fff;padding:20px;}

JavaScript

JavaScript adds interaction.

How It All Works Together

Step 1

We start with HTML.

Step 2

Then we add CSS.

Step 3

Finally, we add JavaScript.
Here’s the cool part: it all works together!

Pro tip: Keep it simple and have fun!

Tips to Customise It

We can change colors.
We can add more text.
Let me explain what’s happening here: we can make it our own!
Learn more about JavaScript

Conclusion

We did it! We built a Sparkly Spoiler text effect.

Great job! You should be proud!

Check out CSS-Tricks for more cool effects.
Also, check out React State vs Props: Visual Component Tree Breakdown and JavaScript Fetch API Tutorial: Modern Data Fetching with HTML, CSS for more tutorials.


Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *