Hidden radio button but box around it in ie8

2019-01-29 05:25发布

问题:

I have style my radio buttons with a background image, basically what i have done is

<input type="radio" id="btn" name="btn" style="opacity: 0;filter: alpha(opacity = 0);position:absolute;">
<label for="btn">My Text</label> <!--- added styles to it --->

with this i get output something like this

Image1 that shows how the display should be: http://i39.tinypic.com/2vcyidg.png

It works fine in every browser except ie8, in ie8 it shows a dotted box around hidden buttons when a label is selected

Image2 shows the problems in ie8: http://i39.tinypic.com/j8l635.png

I cant choose the property display:none; as in IE browsers it disables the radio buttons so i have to hide it.

How can i hide that dotted box in ie8?

Thank You.

Regards,

Shishant Todi.

回答1:

if you can use javascript:

<input onfocus="this.blur()" type="radio" id="btn" name="btn" style="opacity: 0;filter: alpha(opacity = 0);position:absolute;" />


回答2:

Is there a reason why you're not using <input type="hidden" />?



回答3:

I had a similar issue where my radio buttons and checkboxes were showing borders, but only in IE. In my case, this was a css issue where these inputs were being treated the same as text inputs. I simply defined a new class in the stylesheet and specified a border of zero px.