How can I customize the checkbox size and add border radius to the iCheck plugin?

Incorporating the icheck library into my project, I am eager to customize the checkbox size and add a border-radius to it.

After testing various methods, I haven't achieved the desired outcome yet.

Here is what I have tried:

<html>
<head>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.rawgit.com/bantikyan/icheck-bootstrap/master/icheck-bootstrap.min.css" rel="stylesheet>
    <style>
    .c-radius{
    border-radius:5px;
    }
    </style>
</head>
<body>
    <div class="checkbox icheck-primary">
        <input type="checkbox" checked id="primary" class="c-radius"/>
        <label for="primary">Keep username same as email id</label>
    </div>
</body>
</html>

Answer №1

Insert the following CSS code:

.icheck-primary[class*="icheck-"] > label {
    padding-left: 22px !important;
    line-height: 18px;
}

.icheck-primary[class*="icheck-"] > input:first-child + input[type="hidden"] + label::before, .icheck-primary[class*="icheck-"] > input:first-child + label::before {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    margin-left: -22px;
}

.icheck-primary[class*="icheck-"] > input:first-child:checked + input[type="hidden"] + label::after,
.icheck-primary[class*="icheck-"] > input:first-child:checked + label::after {
    top: 0px;
    width: 4px;
    height: 8px;
    left: 0px;
}

.icheck-primary[class*="icheck-"] > label{
  padding-left:22px !important;
  line-height: 18px;
}
.icheck-primary[class*="icheck-"] > input:first-child + input[type="hidden"] + label::before, .icheck-primary[class*="icheck-"] > input:first-child + label::before{
  width:18px;
  height:18px;
  border-radius:5px;
  margin-left:-22px;
}

.icheck-primary[class*="icheck-"] > input:first-child:checked + input[type="hidden"] + label::after, 
.icheck-primary[class*="icheck-"] > input:first-child:checked + label::after{
  top:0px;
  width: 4px;
  height: 8px;
  left:0px;
}
<html>
<head>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.rawgit.com/bantikyan/icheck-bootstrap/master/icheck-bootstrap.min.css" rel="stylesheet">
    <style>
    .c-radius{
    border-radius:5px;
    }
    </style>
</head>
<body>
    <div class="checkbox icheck-primary">
        <input type="checkbox" checked id="primary" class="c-radius"/>
        <label for="primary">Keep username same as email id</label>
    </div>
</body>
</html>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Can inline styling be overridden with CSS?

<td class="subrubr" nowrap="nowrap" valign="bottom"> <a name=""></a> Some lengthy text to be shown here. </td> This snippet of code is automatically created by a PHP script. However, ...

What is the best way to exclude an external HTML file from being displayed on the home page?

shopping_cart.php <div id="main-container"> <div class="container"> <span class="top-label"> <span class="label-txt">Shopping Cart</span> </span> <div class="content-area"> <div class="con ...

Expand the object by clicking on it, causing the surrounding objects to move outside the viewport instead of appearing below

I'm facing a challenge with 3 squares inside one container, each occupying 33.33% of the viewport and placed next to each other. When I click on one square, it should expand to full viewport width and reveal hidden content, while the other two remain ...

Tips for efficiently delivering the create-react-app index file from your server

I have encountered a challenge in my development work with create-react-app. I am looking to serve the index.html file from the backend initially, but I am facing difficulties in achieving this goal. The main reason behind this desire is to customize the ...

The options that are not selected in a dropdown menu will not be added to a different dropdown menu

In my application, I have 2 select boxes. When the user submits the page, only the selected students in the first select box #studentadd are appended to the second select box #studentselect. However, the unselected options from #studentadd do not get appen ...

Modify the presentation URL in struts 2 to conceal query parameters

Although I am aware that utilizing the GET method and passing request parameters in the URL is considered a risky practice due to security vulnerabilities, we find ourselves in a predicament where our project development is nearly finished. Unfortunately, ...

Tips on how to align a label in the middle of a line using HTML and Bootstrap

I'm having trouble creating an inline form with a text and select input. Despite using Bootstrap 5, I can't seem to achieve the desired appearance. <!-- Bootstrap-5 --> <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/e ...

A pair of div containers arranged in rows

I currently have 9 different div containers, each with unique styling for spacing and padding. My goal is to arrange these div cards into 2 rows with sufficient spacing between them for easy readability. As of now, I have all the div containers stacked in ...

Updating a specific row in a table using PHP and SQL

I am having an issue with updating rows in a table that pulls information from a database. Each row has an input tag labeled COMPLETE, which the user can click on to update the database by changing a boolean field from 0 to 1. However, I am facing a prob ...

Creating a PHP form

I am in the process of creating a simple inventory system and I would like to include a drop-down menu for users to select a part and input the quantity. The drop-down menu will be populated with items from a mySQL database. While I am comfortable with myS ...

Custom 404 Page by Google

Could anyone provide information on the property #goog-fixurl for the custom 404 widget? I've searched but can't seem to find any documentation on it. I'm familiar with all the other property styles #goog-fixurl Any assistance would be grea ...

Ways to efficiently populate several dropdown menus with jQuery by making a single request to a local JSON file

I am running into an issue with the Country/City dropdowns in my project. Every time I try to change the countries, I encounter an unexpected behavior. How can I efficiently fetch the local JSON file to populate multiple dropdowns with just one request? Ta ...

Is it possible to modify the appearance of the element that was just clicked on?

Hello everyone, I'm currently working on a form with different inputs, all with the same class: <input type="text" name="username" class="field" /> <input type="text" name="email" class="field" /> I'm trying to figure out how to ch ...

Is it possible to extract around 10 variables from a JavaScript code, then display them on a webpage after execution?

I have just completed writing a Javascript code with around 3,000 lines. This code contains over 60 variables, but there are a few specific variables that I would like to display on my main HTML page. These variables include: totalTime longitudinalAcceler ...

Image floating with varying width and title with a background image

Here is the code I am currently working with: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <t ...

Having trouble getting the Bootstrap theme to work with Django because Load Static is not functioning properly

I recently downloaded a Bootstrap theme called "modern-business" and attempted to integrate it with my Django application. After the integration, the page looked like this: View how it looks However, I was expecting it to look more like this: View how it ...

Is it possible to encounter an error when attempting to read innerHTML of an undefined element in Selenium,

While running a Python script with Selenium and Chrome-driver, an issue arose when the driver tried to execute a JavaScript segment and returned: Message: unknown error: Cannot read property 'innerHTML' of undefined Here is the segment in quest ...

Tips for relocating anchor elements to less desirable locations

My website has an issue with anchor elements appearing too frequently and not in the desired location. I need someone to help fix this so there are only two anchors displayed. After checking my code, it seems like there are not more than the specified num ...

Download or export the HTML source code with embedded iFrame HTML

When using FireBug, the HTML view shows the complete HTML of the page, including that of the iFrames. Is there a method to preserve this same HTML view or perhaps utilize another Firefox extension to save the entire HTML? This would entail having the sav ...

Connect the internal hyperlinks on a webpage to load dynamically without causing a rise in the analytics bounce rate

To keep visitors on my webpage without reloading it, I implemented the Jquery bind option to dynamically load specific parts of the page when anchor links are clicked. This allows the Jquery music player (which features static content) on the site to play ...