How we can create a toggle button with an image masking? Solution: See this CSS Cat Meme Toggle Button With Checkbox, Women Yelling At Cat Viral Meme Toggle Switch.
Earlier I have shared some Toggle Button program, but it is a little different from those because it has an image mask in button. Basically, Toggle button means if you need to button with two options like Play/Stop in a button at that time on the first click it will be working as a play button and second time working as a stop button this is a toggle button. And we can create this type of toggle switch using the radio input and checkbox method also.
Today you will learn to create a toggle button with famous Women Yelling At Cat meme mask. Basically, there is a toggle button and it is for indicating dark and light mode, but you can use according to your choice. First, you will see the famous meme lady’s face and text on the opposite side “It’s Light Mode”. And on click, the toggle will switch to the cat face and the text reveal on another side “No, Night Mode”. It is a funny concept, developers and website owner who is a meme lover, they will love it.
So, Today I am sharing CSS Cat Meme Toggle Button With Checkbox. There I have used pure CSS and HTML for creating this program, there is no JS or any JS library. This is a good and funny example of how we can use HTML CSS together for creating amazing stuff. If you like meme and development both, then you can use this program on your website as dark/light mode toggle or anything else.
If you are thinking now how this meme toggle actually is, then see the preview given below.
Preview Of Women Yelling At Cat Dark/Light Mode Toggle Switch
See this video preview to getting an idea of how this toggle button looks like.
Now you can see this visually, also you can see it live by pressing the button given above. If you like this, then get the source code of its.
You May Also Like:
CSS Cat Meme Toggle Button With Checkbox Source Code
Before sharing source code, let’s talk about it. First I have created checkbox input using HTML <input type="checkbox"> tag and a label for the input. Inside the label, I have placed 3 divs inside it for circle shape and two texts. The texts are dark and light mode, and the circle is for showing the button or switch.
Now using CSS I have placed all the elements in the right place, as you can see in the preview. With CSS first did the checkbox display none, and gave the size to the label and contents inside it. Inside the circle, I have placed the meme image and gave the background-size according to the label’s size. On clicking the circle changing margin and image changing the background size.
Left all other things you will understand after getting the codes, I can’t explain all in writing. For creating this program you have to create only 2 files, one for HTML and one for CSS. Follow the steps to creating this without any error.
index.html
Create an HTML file named ‘index.html‘ and put these codes given here.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<!DOCTYPE html> <!-- Code By Webdevtrick ( https://webdevtrick.com ) --> <html lang="en" > <head> <meta charset="UTF-8"> <title>Meme Toggle Button | Webdevtrick.com</title> <link href="https://fonts.googleapis.com/css?family=Fredoka+One&display=swap" rel="stylesheet"> <link rel="stylesheet" href="style.css"> </head> <body> <input type="checkbox" id="toggle"> <label id="TGswitch" for="toggle"> <div id="circle"></div> <div id="text">It's<br>Light Mode</div> <div id="text2">No,<br>Dark Mode</div> </label> </body> </html> |
style.css
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
/* Code By Webdevtrick ( https://webdevtrick.com ) */ * { user-select: none; -webkit-tap-highlight-color:transparent; } body { font-family: 'Fredoka One', cursive; } input[type="checkbox"] { display: none; } #TGswitch { margin: 0 auto; margin-top: 15%; position: relative; display: block; width: 700px; height: 350px; background-color: #ff2c2c; border-radius: 350px; cursor: pointer; } #circle { width: 290px; height: 290px; background-image: url(https://webdevtrick.com/wp-content/uploads/meme.jpg); background-color: white; background-size: 650px; position: relative; top: 20px; left: 20px; border: 10px solid white; border-radius: 290px; transition: 0.4s ease left, 0.4s ease background-position; z-index: 2; } #text, #text2 { position: absolute; top: 50%; transform: translateY(-50%); color: #fff; font-size: 50px; font-weight: 300; margin-left: 375px; z-index: 1; } #text2 { margin-left: 30px; } #toggle:checked + #TGswitch #circle { left: 370px; background-position: -350px 0; } #toggle:checked + #TGswitch { background: #212121; } |
That’s It. Now you have successfully created CSS Cat Meme Toggle Button With Checkbox, Famous Women Yelling At Cat Meme Dark/Light Mode Toggle. If you have any doubt or question then comment down below.
Thanks For Visiting, Keep Visiting.
Hahaha .. this meme.
Thanks for this amazing article.
Hehe, Thanks for the comment. Stay connected.
Hi Shaan…
Nice article, I’m your follower… Using your tips….