Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android webview radio button and check box styles

Working with android webviews for radio buttons and check box, I tried so many styling with standard html markup but its not showing proper. Its alwyas comes up very small with HDPI,XHDPI and with Tab.

Styles used for check boxes

input[type="checkbox"] {
width: 18px;
padding: 2% 1%;
height: 18px;
margin: 2px 0;
}

Styles used for radio buttons

      input[type="radio"] {
        width: 1em;
        height: 1em;
        -webkit-border-radius: 1em;
        border-radius: 1em;
      }

Html Markup used for radio button

<input type="radio" name="select_ship_address" id="shippingInfo"/>

Html Markup used for Check boxes

<input class="floatLeft AddressTxt" tabindex="10" type="checkbox" id="optionOne" name="customer" rel="optional" value="yes" checked="">

Anyone has any idea. Please help me.

Ex: Screenshot taken from Tab

enter image description here

like image 859
Soarabh Avatar asked Nov 22 '12 21:11

Soarabh


People also ask

Can you style an HTML radio button to look like a checkbox?

Previously, the only way to override the default appearance of HTML radio buttons and checkboxes was to hide it and employ SVG images and JavaScript code. Now, thanks to The CSS appearance property and HTML checkmark symbol, we can achieve the same result using pure CSS.

Can you style radio buttons?

With some simple and modern CSS, we can now style radio button input elements even easier. Below are three different options, each having its pros and cons.

What is the main difference between a radio button and check box?

Checkboxes and radio buttons are elements for making selections. Checkboxes allow the user to choose items from a fixed number of alternatives, while radio buttons allow the user to choose exactly one item from a list of several predefined alternatives.


1 Answers

Simply add -webkit-appearance:none to your CSS. Then you can totally style this kind of elements.

So your code would be like:

input[type="checkbox"] {
    -webkit-appearance:none;
    width: 18px;
    padding: 2% 1%;
    height: 18px;
    margin: 2px 0;
}

and

  input[type="radio"] {
    -webkit-appearance:none
    width: 1em;
    height: 1em;
    -webkit-border-radius: 1em;
    border-radius: 1em;
  }

Note: Just remember that this property removes any kind of style from the element, so you will have to re-style it totally.

In this blog post from CSS Tricks you can read more about appearance, and its compatibility across browsers.

like image 66
Claudio Holanda Avatar answered Oct 31 '22 19:10

Claudio Holanda