How to Customize Checkbox Using CSS?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ashish Bisht
    Banned
    New Member
    • Jul 2016
    • 13

    How to Customize Checkbox Using CSS?

    Hi friends ,
    I want to customize checkbox with the help of CSS. Mostly developers use javascript for customizing the look of the checkboxes but I want to use CSS. I hope any tech developer can help me over here in resolving the issue.
    Last edited by Niheel; Jan 27 '17, 10:17 AM.
  • devcake
    New Member
    • Oct 2016
    • 4

    #2
    Hello,
    You can hide the input using display: none; and add extra element which will take over the function of your checkbox. Than you can style that element to look like checkbox button you need.

    Example:

    HTML:
    Code:
    <span class="list-item">
      <label>
        <input type="checkbox" name="name" value="YourValueName">
        <span class="list-item-label">YourValueName</span>
      </label>
    </span>
    CSS:
    Code:
    .list-item input[type='checkbox'] {
        display: none;
    }
    
    .list-item input[type='checkbox'] + span {
        position: relative;
        padding-left: 12px;
        padding-right: 13px;
    }
    
    .list-item input[type='checkbox'] + span:before {
        position: absolute;
        left: -8px;
        top: 50%;
        width: 13px;
        height: 13px;
        display: inline-block;
        content: '';
        margin: 0;
        clear: none;
        cursor: pointer;
        background: #e1e1e1;
        margin-top: -7.5px;
    }
    
    .list-item input[type='checkbox']:checked + span:before  {
        background: #2f355b;
    }
    Last edited by devcake; Oct 26 '16, 01:46 PM. Reason: Not finished yet

    Comment

    • simondgear
      New Member
      • Nov 2016
      • 1

      #3
      Hi Buddy

      I refer useful & helpful article.I hope it will solve your issue.

      In this blog, I have described how to create custom checkbox using css only or pure css. You can create webpage more attractive using this stylish ch


      https://www.creativejui z.fr/blog/en/tutorials/customize-checkbox-and-radio-button-with-css


      Thanks

      Comment

      Working...