Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove border circle from radio input

Tags:

html

css

I wanted to use image instead of regular radio inputs.

enter image description here enter image description here

I made it this way:

input[type="radio"]{
    content:url('/images/new-home-page/Checkbox.png');
    height:3vh;
    width:3vh;
}
input[type="radio"]:checked{
    content:url('/images/new-home-page/checkedCheckbox.png');
}

Unfortunately, they have circles around them. I have tried to use border:none or text-decoration:none but it doesnt help. Could someone help me with this please?

They look like this now:

enter image description here

like image 258
divHelper11 Avatar asked Dec 15 '15 10:12

divHelper11


People also ask

How do I display radio buttons side by side?

To make a horizontal radio button set, add the data-type="horizontal" to the fieldset . The framework will float the labels so they sit side-by-side on a line, hide the radio button icons and only round the left and right edges of the group.

How do you change the fill color on a radio button?

The accent-color just changes the theme color of radio buttons — this is enough for most use cases. However if you are looking to fully customize the radio button (changing border, padding, background etc) — the CSS appearance property can be used to do so.


2 Answers

I would request you to use the appearance property of CSS, which is responsible for the components like this. So setting the appearance: none will make a kind of display: none to the component's appearance, which is what is needed for you. You are good to use this bit of CSS to make the component not display, while keeping the element in the view:

-webkit-appearance: none;
-moz-appearance: none;
-ms-appearance: none;
-o-appearance: none;
appearance: none;

Snippet

input {
  content: url('http://i.stack.imgur.com/M3EkO.png');
  height: 16px;
  width: 16px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}
input:checked {
  content: url('http://i.stack.imgur.com/Ialva.png');
}
Checkbox:
<input type="checkbox" name="" id="" /> <br />
Radios:
<input type="radio" name="Hi" id="" />
<input type="radio" name="Hi" id="" />

Output: http://output.jsbin.com/digebimolu/1

like image 179
Praveen Kumar Purushothaman Avatar answered Sep 21 '22 08:09

Praveen Kumar Purushothaman


You must hide radio buttons and add more elements like <span> and <label>

Here is how it should work: http://jsfiddle.net/etz9Lfat/

like image 37
MurDaD Avatar answered Sep 21 '22 08:09

MurDaD