TimesCoding

Learn, Practice, and Excel with our Coding Tutorials!

Pure CSS Custom Modern and Stylish Checkboxes

May 31, 2024 3 Min read CSS HTML
Stylish Checkboxes

Creating a custom modern and stylish checkboxes using pure CSS can enhance the visual appeal of your web forms. Here’s a simple and elegant checkboxes you can use it in your web forms.

HTML code for Checkboxes

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Custom Checkboxes</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <form>
        <h2>Select Programming Languages</h2>
        <label class="custom-checkbox">
            <input type="checkbox" value="Python" />
            <span class="checkmark"></span>
            Python
        </label>
        <label class="custom-checkbox">
            <input type="checkbox" value="JavaScript" />
            <span class="checkmark"></span>
            JavaScript
        </label>
        <label class="custom-checkbox">
            <input type="checkbox" value="Java" />
            <span class="checkmark"></span>
            Java
        </label>
        <label class="custom-checkbox">
            <input type="checkbox" value="C++" />
            <span class="checkmark"></span>
            C++
        </label>
    </form>
</body>
</html>

CSS code for Checkboxes

body {
    font-family: Arial, sans-serif;
    background-color: #f0f0f0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

form {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

h2 {
    margin-bottom: 20px;
    font-size: 24px;
    color: #333;
    text-align: center;
}

.custom-checkbox {
    display: block;
    position: relative;
    padding-left: 35px;
    margin-bottom: 20px; /* Increased gap between checkboxes */
    cursor: pointer;
    font-size: 18px;
    user-select: none;
}

.custom-checkbox input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 25px;
    width: 25px;
    background-color: #ffcccc; /* Light red background color */
    border: 2px solid #cc0000; /* Bold red border */
    border-radius: 4px;
    transition: background-color 0.3s, box-shadow 0.3s, border-color 0.3s;
}

.custom-checkbox input:checked ~ .checkmark {
    background-color: #cc0000; /* Darker red when checked */
    box-shadow: 0 0 10px rgba(204, 0, 0, 0.6);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.custom-checkbox input:checked ~ .checkmark:after {
    display: block;
}

.custom-checkbox .checkmark:after {
    left: 9px;
    top: 5px;
    width: 6px;
    height: 12px;
    border: solid white;
    border-width: 0 3px 3px 0;
    transform: rotate(45deg);
}

Hope this code will help you to design your web forms stylish.

Tags:

  1. “How to create custom checkboxes with pure CSS”
  2. “Modern CSS checkbox design tutorial”
  3. “Stylish checkbox styling with CSS”
  4. “Pure CSS custom checkbox examples”
  5. “CSS checkbox with custom background and border”
  6. “Responsive custom checkboxes using CSS”
  7. “Designing checkboxes with CSS only”
  8. “Checkbox styling for programming languages with CSS”
  9. “Step-by-step guide to CSS custom checkboxes”
  10. “Advanced CSS techniques for custom checkboxes”
Related Post:
Trendy Website Color Combinations for 2024 − Here are some trending color combinations to consider for your website, including header, footer, sidebar, and content section colors with codes: 1. Balanced Brights: 2..
Create a Stylish Analog Watch with HTML, CSS, and JavaScript − Creating a stylish analog watch using HTML, CSS, and JavaScript involves simulating the appearance and movement of clock hands. We’ll build a simple analog clock.
How to Create a Stylish Digital Watch with HTML, CSS, and JavaScript − Creating a digital watch similar to an Apple Watch using HTML, CSS, and JavaScript involves several steps. We’ll build a simple, functional digital clock that.
Creating a Stylish and Responsive Bootstrap Menu with Colorful Toggle Icon − Below is a simple responsive Bootstrap 5 template that you can use as a starting point for your project. This template includes a stylish &.
Responsive Web Design with CSS: A Short Tutorial − Responsive web design is a crucial aspect of modern web development. It ensures that your website looks and functions well on a variety of devices,.
How to Create a Modern Stylish Accordion with Arrows Using Only HTML and CSS − This modern and stylish accordion is created using only HTML and CSS, featuring smooth transitions and interactive arrows that change direction upon expansion. It’s perfect.
How to Create a Stylish and Modern HTML Select Field Using CSS − Creating a modern and stylish HTML “Select” field involves using CSS to enhance the default styling. Here’s an example of how you can achieve this:.
Modern and Stylish Button with Gradient and Hover Effects − This modern and stylish button features a vibrant gradient background that seamlessly transitions on hover, coupled with a subtle box shadow for added depth. Its.
Creating a Modern Responsive Menu with HTML & CSS Only − Learn how to design a stylish and modern website header section and responsive menu using just HTML and CSS, with a responsive menu that toggles.
Design a Modern and Stylish Login Form using HTML and CSS − This is a modern and stylish login form using HTML and CSS, featuring 3D effects, colorful fields, and a button. The “Not registered? Create an.
Creating a Modern Button with Stylish Hover Effects Using CSS − This is a modern and stylish button with a simple hover effect using CSS. The button has a bold border & the border color will.
How to Create a Colorful Tic-Tac-Toe Game with HTML, CSS and JavaScript − Here’s a colorful Tic-Tac-Toe game implemented using HTML, CSS, and JavaScript only. The game includes a restart button, winner message, and special effects for the.