About www.anthony.blog.br
If you're trying to create a rainy background for your website or JavaScript game, you've come to the right place. In this guide, I’ll show you how to 'make the web wet' using only HTML, CSS, and vanilla JavaScript. No frameworks needed. One of the special features of this effect is that it saves the drops' positions, so when you refresh the page, they continue exactly where they were. This creates a sense of continuity and makes your program feel more natural.
www.asciiart.eu
_____ _____ _____ _____ _____ _____ _____ _______ _____ _____ _____ _____ _____ _____ _____ _____ _______ _______ _____ _____ _____ _______ _____
/\ \ /\ \ /\ \ /\ \ /\ \ /\ \ /\ \ /::\ \ /\ \ |\ \ /\ \ /\ \ /\ \ /\ \ /\ \ /\ \ /::\ \ /::\ \ /\ \ /\ \ /\ \ /::\ \ /\ \
/::\ \ /::\____\ /::\ \ /::\ \ /::\____\ /::\ \ /::\____\ /::::\ \ /::\____\ |:\____\ /::\ \ /::\____\ /::\____\ /::\ \ /::\____\ /::\ \ /::::\ \ /::::\ \ /::\____\ /::\ \ /::\____\ /::::\ \ /::\ \
\:::\ \ /:::/ / /::::\ \ /::::\ \ /::::| | \:::\ \ /:::/ / /::::::\ \ /::::| | |::| | /::::\ \ /::::| | /:::/ / /::::\ \ /:::/ / /::::\ \ /::::::\ \ /::::::\ \ /::::| | /::::\ \ /:::/ / /::::::\ \ /::::\ \
\:::\ \ /:::/ / /::::::\ \ /::::::\ \ /:::::| | \:::\ \ /:::/ / /::::::::\ \ /:::::| | |::| | /::::::\ \ /:::::| | /:::/ / /::::::\ \ /:::/ / /::::::\ \ /::::::::\ \ /::::::::\ \ /:::::| | /::::::\ \ /:::/ / /::::::::\ \ /::::::\ \
\:::\ \ /:::/ / /:::/\:::\ \ /:::/\:::\ \ /::::::| | \:::\ \ /:::/ / /:::/~~\:::\ \ /::::::| | |::| | /:::/\:::\ \ /::::::| | /:::/ / /:::/\:::\ \ /:::/ / /:::/\:::\ \ /:::/~~\:::\ \ /:::/~~\:::\ \ /::::::| | /:::/\:::\ \ /:::/ / /:::/~~\:::\ \ /:::/\:::\ \
\:::\ \ /:::/____/ /:::/__\:::\ \ /:::/__\:::\ \ /:::/|::| | \:::\ \ /:::/____/ /:::/ \:::\ \ /:::/|::| | |::| | /:::/__\:::\ \ /:::/|::| | /:::/ / /:::/__\:::\ \ /:::/____/ /:::/__\:::\ \ /:::/ \:::\ \ /:::/ \:::\ \ /:::/|::| | /:::/__\:::\ \ /:::/ / /:::/ \:::\ \ /:::/ \:::\ \
/::::\ \ /::::\ \ /::::\ \:::\ \ /::::\ \:::\ \ /:::/ |::| | /::::\ \ /::::\ \ /:::/ / \:::\ \ /:::/ |::| | |::| | \:::\ \:::\ \ /:::/ |::| | /:::/ / \:::\ \:::\ \ /::::\ \ /::::\ \:::\ \ /:::/ / \:::\ \ /:::/ / \:::\ \ /:::/ |::| | /::::\ \:::\ \ /:::/ / /:::/ / \:::\ \ /:::/ \:::\ \
/::::::\ \ /::::::\ \ _____ /::::::\ \:::\ \ /::::::\ \:::\ \ /:::/ |::| | _____ /::::::\ \ /::::::\ \ _____ /:::/____/ \:::\____\ /:::/ |::| | _____ |::|___|______ ___\:::\ \:::\ \ /:::/ |::|___|______ /:::/ / _____ ___\:::\ \:::\ \ /::::::\ \ _____ /::::::\ \:::\ \ /:::/____/ \:::\____\ /:::/____/ \:::\____\ /:::/ |::|___|______ /::::::\ \:::\ \ /:::/ / /:::/____/ \:::\____\ /:::/ / \:::\ \
/:::/\:::\ \ /:::/\:::\ \ /\ \ /:::/\:::\ \:::\ \ /:::/\:::\ \:::\ \ /:::/ |::| |/\ \ /:::/\:::\ \ /:::/\:::\ \ /\ \ |:::| | |:::| | /:::/ |::| |/\ \ /::::::::\ \ /\ \:::\ \:::\ \ /:::/ |::::::::\ \ /:::/____/ /\ \ /\ \:::\ \:::\ \ /:::/\:::\ \ /\ \ /:::/\:::\ \:::\____\ |:::| | |:::| ||:::| | |:::| | /:::/ |::::::::\ \ /:::/\:::\ \:::\ ___\ /:::/ / |:::| | |:::| | /:::/ / \:::\ ___\
/:::/ \:::\____\/:::/ \:::\ /::\____\/:::/__\:::\ \:::\____\ /:::/ \:::\ \:::\____\/:: / |::| /::\____\ /:::/ \:::\____\/:::/ \:::\ /::\____\|:::|____| |:::| |/:: / |::| /::\____\ /::::::::::\____\/::\ \:::\ \:::\____\ /:::/ |:::::::::\____\|:::| / /::\____\/::\ \:::\ \:::\____\/:::/ \:::\ /::\____\/:::/ \:::\ \:::| ||:::|____| |:::| ||:::|____| |:::| |/:::/ |:::::::::\____\ /:::/__\:::\ \:::| |/:::/____/ |:::|____| |:::| |/:::/____/ ___\:::| |
/:::/ \::/ /\::/ \:::\ /:::/ /\:::\ \:::\ \::/ / \::/ \:::\ /:::/ /\::/ /|::| /:::/ / /:::/ \::/ /\::/ \:::\ /:::/ / \:::\ \ /:::/ / \::/ /|::| /:::/ / /:::/~~~~/~~ \:::\ \:::\ \::/ / \::/ / ~~~~~/:::/ /|:::|____\ /:::/ /\:::\ \:::\ \::/ /\::/ \:::\ /:::/ /\::/ |::::\ /:::|____| \:::\ \ /:::/ / \:::\ \ /:::/ / \::/ / ~~~~~/:::/ / \:::\ \:::\ /:::|____|\:::\ \ \:::\ \ /:::/ / \:::\ \ /\ /:::|____|
/:::/ / \/____/ \/____/ \:::\/:::/ / \:::\ \:::\ \/____/ \/____/ \:::\/:::/ / \/____/ |::| /:::/ / /:::/ / \/____/ \/____/ \:::\/:::/ / \:::\ \ /:::/ / \/____/ |::| /:::/ / /:::/ / \:::\ \:::\ \/____/ \/____/ /:::/ / \:::\ \ /:::/ / \:::\ \:::\ \/____/ \/____/ \:::\/:::/ / \/____|:::::\/:::/ / \:::\ \ /:::/ / \:::\ \ /:::/ / \/____/ /:::/ / \:::\ \:::\/:::/ / \:::\ \ \:::\ \ /:::/ / \:::\ /::\ \::/ /
/:::/ / \::::::/ / \:::\ \:::\ \ \::::::/ / |::|/:::/ / /:::/ / \::::::/ / \:::\ /:::/ / |::|/:::/ / /:::/ / \:::\ \:::\ \ /:::/ / \:::\ \ /:::/ / \:::\ \:::\ \ \::::::/ / |:::::::::/ / \:::\ /:::/ / \:::\ /:::/ / /:::/ / \:::\ \::::::/ / \:::\ \ \:::\ /:::/ / \:::\ \:::\ \/____/
/:::/ / \::::/ / \:::\ \:::\____\ \::::/ / |::::::/ / /:::/ / \::::/ / \:::\__/:::/ / |::::::/ / /:::/ / \:::\ \:::\____\ /:::/ / \:::\ /:::/ / \:::\ \:::\____\ \::::/ / |::|\::::/ / \:::\__/:::/ / \:::\__/:::/ / /:::/ / \:::\ \::::/ / \:::\ \ \:::\__/:::/ / \:::\ \:::\____\
\::/ / /:::/ / \:::\ \::/ / /:::/ / |:::::/ / \::/ / /:::/ / \::::::::/ / |:::::/ / \::/ / \:::\ /:::/ / /:::/ / \:::\__/:::/ / \:::\ /:::/ / /:::/ / |::| \::/____/ \::::::::/ / \::::::::/ / /:::/ / \:::\ /:::/ / \:::\ \ \::::::::/ / \:::\ /:::/ /
\/____/ /:::/ / \:::\ \/____/ /:::/ / |::::/ / \/____/ /:::/ / \::::::/ / |::::/ / \/____/ \:::\/:::/ / /:::/ / \::::::::/ / \:::\/:::/ / /:::/ / |::| ~| \::::::/ / \::::::/ / /:::/ / \:::\/:::/ / \:::\ \ \::::::/ / \:::\/:::/ /
/:::/ / \:::\ \ /:::/ / /:::/ / /:::/ / \::::/ / /:::/ / \::::::/ / /:::/ / \::::::/ / \::::::/ / /:::/ / |::| | \::::/ / \::::/ / /:::/ / \::::::/ / \:::\ \ \::::/ / \::::::/ /
/:::/ / \:::\____\ /:::/ / /:::/ / /:::/ / \::/____/ /:::/ / \::::/ / /:::/ / \::::/ / \::::/ / /:::/ / \::| | \::/____/ \::/____/ /:::/ / \::::/ / \:::\____\ \::/____/ \::::/ /
\::/ / \::/ / \::/ / \::/ / \::/ / ~~ \::/ / \::/ / \::/ / \::/____/ \::/ / \::/ / \:| | ~~ ~~ \::/ / \::/____/ \::/ / ~~ \::/____/
\/____/ \/____/ \/____/ \/____/ \/____/ \/____/ \/____/ \/____/ ~~ \/____/ \/____/ \|___| \/____/ ~~ \/____/
In your CSS file, you’ll need to set some properties for the 'rain' container. To make the effect cover the entire screen, set the height to 100vh and the width to 100vw. You should also use position: fixed, so the rain stays in place even when you're scrolling through the rest of the page.
As for the drops (which we’ll create with JavaScript in the next steps), I’ve given them a 'raindrop look' by using border-radius, a color gradient, and proportions that mimic a real drop. To make the effect even more realistic, we’ll also rotate the drops by a few degrees.
style.css
#rain {
height: 100vh;
width: 100vw;
position: fixed;
z-index: 0;
}
.drops {
border-radius: 50%;
background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.205));
position:absolute;
width:2px;
height:10px;
transform: rotate(-12deg);
}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.