radio button with custom background image turns black in internet explorer - html

I need to render radiobuttons on my site with specific background-images:
not checked
, checked
I solved this problem by adding the following styles for radiobutton elements:
{
width: 20px;
height: 20px;
-webkit-appearance: none;
background-image: url(/Images/notChackedRadioButton.png);
background-repeat: no-repeat;
}
Everything was fine, but when i open my site in Internet Explorer I see that all radiobuttons became black.
Seems like IE adds its own image above my background image, but I don't have any idea how to solve this. Please, any suggestions will be helpful.

Not knowing the rest of your code here is an example of a way you can do it. Works in IE 11 and IE Edge. Found on codepen for rest of the example - https://codepen.io/tutsplus/pen/bgqYJz
input[type="radio"] {
display:none;
}
input[type="radio"] + label span {
display:inline-block;
width:19px;
height:19px;
margin:-2px 10px 0 0;
vertical-align:middle;
background:url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/210284/check_radio_sheet.png) -38px top no-repeat;
cursor:pointer;
}
input[type="radio"]:checked + label span {
background:url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/210284/check_radio_sheet.png) -57px top no-repeat;
}
<input type="radio" id="r1" name="rr" />
<label for="r1"><span></span>Radio Button 1</label>
<p>
<input type="radio" id="r2" name="rr" />
<label for="r2"><span></span>Radio Button 2</label>

Related

Custom checkbox in Safari

I created custom radio input
My code:
.options input[type="radio"] {
display: none;
-webkit-appearance: none;
}
.options input[type="radio"]:checked + .poll-field img {
opacity: 1;
filter: alpha(opacity=1);
background-size: 100%;
background-position: center;
background-image: url("https://example.com/img/checkmark.png");
background-repeat: no-repeat;
}
<div class="col-12 col-md-8 options">
<label for="p2_1_1">
<input type="radio" name="p2_1" value="1" id="p2_1_1"/>
<div class="poll-field">
<span class="poll-text">1</span>
<img src="{{ asset('img/check_empty.png') }}" class="poll-img-check">
</div>
</label>
</div>
It works on Chrome, Firefox, even on IE, but not on Safari (13.0.4).
On Safari I can mark only the first option. When I try to select a different number than "1" - the checkmark didn't appear.
Checkmarks only appear when I open web inspector, pick ANY element and unmark and mark some CSS rule (in any CSS class).
Have someone similar problem or have any idea to solve this?
I added this and it fixed all
.options input[type="radio"]:checked + .poll-field {
background-color: white;
}

Change the outlook of checkbox as image

Hi I have different check boxes and I want to have an image instead of the check boxes so if I click the image the background should change so as to indicate whether it is checked or not.
As I have different checkboxes so I cannot put the background as an image in the CSS.
Please suggest how should I go ahead.
See Here. You can apply this to your code and have the custom background
HTML:
<div class="amPmCheckbox">
<input type="checkbox" name="data[Child][remember_me]" class="checkboxLabel main_street_input" id="am_2" value="1" />
<label for="am_2">AM</label>
</div>
CSS:
.amPmCheckbox input[type="checkbox"] {
display: none;
}
.amPmCheckbox input[type="checkbox"]+label {
background: url('http://renegadeox.com/img/off.png') no-repeat;
height:17px;
padding-left: 18px;
}
.amPmCheckbox input[type="checkbox"]:checked + label {
background: url('http://renegadeox.com/img/on.png') no-repeat;
height:17px;
}
http://jsfiddle.net/JkDhN/1/

css - replacing checkbox image

Hi I know this has been answered but I can't get it to work for me.
I have as HTML
<input type="hidden" name="data[Child][remember_me]" id="am_2_" value="0"/>
<input type="checkbox" name="data[Child][remember_me]" class="checkboxLabel main_street_input" id="am_2" value="1"/>
<label for="am_2"> </label>
and then
.amPmCheckbox input[type="checkbox"]{
display: none;}
.amPmCheckbox input[type="checkbox"]+label{
background: url('http://renegadeox.com/img/off.png') no-repeat; width:16px; height:17px;}
.amPmCheckbox input[type="checkbox"]:checked + label {
background: url('http://renegadeox.com/img/on.png');width:16px; height:17px;}
But it's not picking up the checked image. I can't figure out what's the problem, anyone any ideas? heres a fiddle btw
http://jsfiddle.net/ksCk8/
It picks up the checked image when the checkbox is checked. Issue you have is the fact nothing is clickable to make the checkbox checked.
Move the AM/PM into the label and use padding to shove it over instead of the spaces.
HTML:
<div class="amPmCheckbox">
<input type="checkbox" name="data[Child][remember_me]" class="checkboxLabel main_street_input" id="am_2" value="1" />
<label for="am_2">AM</label>
</div>
CSS:
.amPmCheckbox input[type="checkbox"] {
display: none;
}
.amPmCheckbox input[type="checkbox"]+label {
background: url('http://renegadeox.com/img/off.png') no-repeat;
height:17px;
padding-left: 18px;
}
.amPmCheckbox input[type="checkbox"]:checked + label {
background: url('http://renegadeox.com/img/on.png') no-repeat;
height:17px;
}
http://jsfiddle.net/JkDhN/1/

Radio Buttons Styles in Chrome correctly - not working in Firefox

(Both Browser's latest Versions in place - Form is output by Gravity Forms so can't do much with the html architecture)
I basically have the output in Chrome perfectly - it's a circle with a border and central white space that fills background in (to be a full colored circle) when clicked.
However, even when I"m turning off -moz-appearance in Firefox, it's not styling at all - just giving me a flat, black radio button. Code below: ANy help would be appreciated.
body .gform_body .gfield ul.gfield_radio li input{
-webkit-appearance: none;
-moz-appearance: none;
display: inline-block;
width: 15px !important;
height: 15px !important;
}
body .gform_body .gfield ul.gfield_checkbox li input{
-webkit-appearance: none;
display: inline-block;
width: 15px !important;
height: 15px !important;
}
body .gform_wrapper .gform_body .gform_fields .gfield .gfield_radio input {
border-radius: 8px !important;
border: 4px solid #c4e7e3 !important;
}
html:
<li id="field_1_7" class="gfield radio_1">
<label class="gfield_label">Hello! Are you: </label>
<div class="ginput_container">
<ul class="gfield_radio" id="input_1_7">
<li class="gchoice_7_0">
<input name="input_7" type="radio" value="Ready to get started? "checked="checked" id="choice_7_0" tabindex="3" onclick="gf_apply_rules(1,[8,6]);">
<label for="choice_7_0">Ready to get started? </label></li>
<li class="gchoice_7_1">
<input name="input_7" type="radio" value="Or just saying hello!" id="choice_7_1" tabindex="4" onclick="gf_apply_rules(1,[8,6]);">
<label for="choice_7_1">Or just saying hello!</label></li></ul></div></li>
Any help on route to take is really appreciated.
When you are trying to change the look of form elements (like radio, checkbox and selects) you should change them with some JS code or plugin, because there is too much restriction with css only and you won't get the wanted results on other browsers.
Try something simples as ezMark or some other plugin in order to have the wanted effect.

Force label background: url() In Internet explorer

I have a Html/Css code that work fine in Chrome and firefox but in IE i can't show up the background for my label
i have two class css one for active lable and other for no active.
Here is my Css Code:
.jqTransformDayRadioWrapper label {
width: 31px !important;
height: 28px;
margin-right: 2px;
text-align: center;
font-weight: normal;
line-height: 28px;
cursor: pointer;
background: url('../img/form/day_radio_button.gif') no-repeat;
}
.jqTransformDayRadioWrapper label.active {
background: url('../img/form/day_radio_button_selected.gif') no-repeat !important;
}
And Here is the HTML code generate by Cakephp Html Helper Form :
<div class="jqTransformDayRadioWrapper">
<label for="EventReoccurringOnDay1">S</label>
<input name="data[Event][reoccurring_on_day1]" type="text" class="jqTransformDayRadioWrapper" value="0" id="EventReoccurringOnDay1" />
<label for="EventReoccurringOnDay5">T</label>
<input name="data[Event][reoccurring_on_day5]" type="text" checked="checked" class="jqTransformDayRadioWrapper" value="1" id="EventReoccurringOnDay5" />
</div>
</div>
Thanks in advance:).
You will need to set your label to display:block; because labels are inline elements. And without display:block; your background image will not appear in IE 7.