Pure CSS Toggle Function

Developer
Size
2,566 Kb
Views
10,120

How do I make an pure css toggle function?

Simple method for creating a toggle function using only CSS - no JS required.. What is a pure css toggle function? How do you make a pure css toggle function? This script and codes were developed by James Zedd on 11 October 2022, Tuesday.

Pure CSS Toggle Function Previews

Pure CSS Toggle Function - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Pure CSS Toggle Function</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="container"> <div class="site-title"> <h1>Elite World Explorer</h1> </div> <div class="content"> <h1>5 Best Desinations in the World</h1> <img src="https://placehold.it/700x250" alt="" class="" /> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse eget nulla mollis, efficitur urna nec, viverra dolor. Nulla facilisi. Interdum et malesuada fames ac ante ipsum primis in faucibus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Praesent efficitur finibus eros sit amet sagittis. Ut sollicitudin sodales neque et volutpat. Curabitur dictum ante vel fermentum volutpat. Curabitur ac neque et erat viverra egestas.</p> <label for="showToggle">Show Toggle</label> <input type="checkbox" id="showToggle" /> <div class="toggle-box"> <h2>Sign up for our mailing list</h2> <input type="text" placeholder="First Name" /> <input type="text" placeholder="Email Address" /> <button type="submit">Submit</button> </div> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse eget nulla mollis, efficitur urna nec, viverra dolor. Nulla facilisi. Interdum et malesuada fames ac ante ipsum primis in faucibus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Praesent efficitur finibus eros sit amet sagittis. Ut sollicitudin sodales neque et volutpat. Curabitur dictum ante vel fermentum volutpat. Curabitur ac neque et erat viverra egestas.</p> </div>
</div> <script src="js/index.js"></script>
</body>
</html>

Pure CSS Toggle Function - Script Codes CSS Codes

.container { padding: 20px; font-family: 'Lato', arial, sans-serif; max-width: 700px; margin: 0 auto;
}
.site-title { text-align: center; border-bottom: 1px solid #111111; margin-bottom: 24px;
}
.site-title h1 { font-weight: 300; text-transform: uppercase; letter-spacing: 10px;
}
img { width: 100%;
}
.content p { line-height: 1.6em; margin-bottom: 24px;
}
label { cursor: pointer; padding: 12px 18px; border-radius: 12px; background: #31b0d5; color: #ffffff; transition: all 300ms ease-in-out;
}
label:hover { background: #269abc;
}
#showToggle { display: none;
}
.toggle-box { border-radius: 12px; margin-top: 18px; padding: 0 18px; background: #f1f1f1; height: 0; overflow: hidden; transition: all 300ms linear;
}
.toggle-box h2 { margin-top: 0;
}
.toggle-box input { text-indent: 4px; padding: 4px 0; border-radius: 4px; border: 2px solid #ffffff; margin-bottom: 12px;
}
/*-- The Magic --*/
#showToggle:checked + .toggle-box { padding: 24px 18px; height: 90px;
}
/* -- */
@media (max-width: 550px) { .toggle-box input { display: block; width: 100%; box-sizing : border-box; } #showToggle:checked + .toggle-box { padding: 24px 18px; height: 180px;
}
}

Pure CSS Toggle Function - Script Codes JS Codes

// nothing to see here :P
Pure CSS Toggle Function - Script Codes
Pure CSS Toggle Function - Script Codes
Home Page Home
Developer James Zedd
Username james_zedd
Uploaded October 11, 2022
Rating 3
Size 2,566 Kb
Views 10,120
Do you need developer help for Pure CSS Toggle Function?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

James Zedd (james_zedd) Script Codes
Create amazing blog posts with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!