Checkboxes in web pages – how to make them bigger?

前端 未结 7 1134
南笙
南笙 2021-01-30 01:57

The standard checkboxes rendered in most browsers are quite small and don’t increase in size even when a larger font is used. What is the best, browser-independent way to displ

7条回答
  •  无人及你
    2021-01-30 02:31

    Here's a trick that works in most recent browsers (IE9+) as a CSS only solution that can be improved with javascript to support IE8 and below.

    Style the label with what you want the checkbox to look like

    #checkboxID
    {
      position: absolute fixed;
      margin-right: 2000px;
      right: 100%;
    }
    #checkboxID + label
    {
      /* unchecked state */
    }
    #checkboxID:checked + label
    {
      /* checked state */
    }

    For javascript, you'll be able to add classes to the label to show the state. Also, it would be wise to use the following function:

    $('label[for]').live('click', function(e){
      $('#' + $(this).attr('for') ).click();
      return false;
    });
    

    EDIT to modify #checkboxID styles

提交回复
热议问题