如何改变 FireFox 中单选按钮的样式?
How to change the style of radio button in FireFox?
我尝试更改单选按钮,尝试以下行。除了 Firefox,我的风格在所有浏览器中都是苹果。事实上,我在 Firefox 中看不到样式。
#payment_method_paypal[type='radio']::after {
width: 20px !important;
height: 20px !important;
border-radius: 3px;
top: -6px !important;
left: -1px !important;
position: relative;
background-color: #fff !important;
content: '';
display: inline-block;
visibility: visible;
border: 2px solid #776330 !important;
}
#payment_method_paypal[type='radio']:checked::after {
width: 20px !important;
height: 20px !important;
border-radius: 3px;
top: -6px !important;
left: -1px !important;
position: relative;
background-color: #776330 !important;
content: '';
display: inline-block;
visibility: visible;
border: 2px solid #776330 !important;
box-shadow: inset 0 0 0 2px #fff !important;
margin-left: 6px;
}
#payment_method_stripe[type='radio']::after {
width: 20px !important;
height: 20px !important;
border-radius: 3px;
top: -6px !important;
left: -1px !important;
position: relative;
background-color: #fff !important;
content: '';
display: inline-block;
visibility: visible;
border: 2px solid #776330 !important;
}
#payment_method_stripe[type='radio']:checked::after {
width: 20px !important;
height: 20px !important;
border-radius: 3px;
top: -6px !important;
left: -1px !important;
position: relative;
background-color: #776330 !important;
content: '';
display: inline-block;
visibility: visible;
border: 2px solid #776330 !important;
box-shadow: inset 0 0 0 2px #fff !important;
margin-left: 6px;
}
<input id="payment_method_stripe" type="radio" class="input-radio" name="payment_method" value="stripe" checked="checked" data-order_button_text="">
<label for="payment_method_stripe">Credit / Debit Card</label>
<input id="payment_method_paypal" type="radio" class="input-radio" name="payment_method" value="paypal" data-order_button_text="Proceed to PayPal">
<label for="payment_method_paypal">PayPal</label>
如何在firefox中应用这个样式?
Firefox 不显示的问题是什么?
我已经尝试过以下解决方案:
Styling radio button - not work in IE and Firefox
How to change style of radio and checkbox input
我认为这段代码适合你。
.checkbox {
position: relative;
padding-left: 30px;
margin-right: 20px;
}
.checkbox input {
width: 0;
height: 0;
position: absolute;
}
.checkbox span {
width: 20px;
height: 20px;
border-radius: 3px;
position: absolute;
left: 0;
top: -1px;
background-color: #fff;
content: '';
display: inline-block;
visibility: visible;
border: 2px solid #776330;
box-sizing: border-box;
}
.checkbox span::after {
position: absolute;
content: '';
left: 2px;
top: 2px;
width: 12px;
height: 12px;
background-color: #776330;
display: none;
}
.checkbox input:checked ~ span::after {
display: block;
}
<label class="checkbox" for="payment_method_stripe">
<input id="payment_method_stripe" type="radio" class="input-radio" name="payment_method" value="stripe" checked="checked" data-order_button_text="">
<span></span>
Credit / Debit Card
</label>
<label class="checkbox" for="payment_method_paypal">
<input id="payment_method_paypal" type="radio" class="input-radio" name="payment_method" value="paypal" data-order_button_text="Proceed to PayPal">
<span></span>
PayPal
</label>
我喜欢 Sato 的回答,但您也可以将其添加到您的 CSS:
input[type='radio'] {
-moz-appearance: initial !important;
}
我会尽量避免在您的 CSS 中使用 !important
,这不是一个好的习惯。我认为如果您将它从您的代码中删除,您可能会从我的代码片段中删除它。
我尝试更改单选按钮,尝试以下行。除了 Firefox,我的风格在所有浏览器中都是苹果。事实上,我在 Firefox 中看不到样式。
#payment_method_paypal[type='radio']::after {
width: 20px !important;
height: 20px !important;
border-radius: 3px;
top: -6px !important;
left: -1px !important;
position: relative;
background-color: #fff !important;
content: '';
display: inline-block;
visibility: visible;
border: 2px solid #776330 !important;
}
#payment_method_paypal[type='radio']:checked::after {
width: 20px !important;
height: 20px !important;
border-radius: 3px;
top: -6px !important;
left: -1px !important;
position: relative;
background-color: #776330 !important;
content: '';
display: inline-block;
visibility: visible;
border: 2px solid #776330 !important;
box-shadow: inset 0 0 0 2px #fff !important;
margin-left: 6px;
}
#payment_method_stripe[type='radio']::after {
width: 20px !important;
height: 20px !important;
border-radius: 3px;
top: -6px !important;
left: -1px !important;
position: relative;
background-color: #fff !important;
content: '';
display: inline-block;
visibility: visible;
border: 2px solid #776330 !important;
}
#payment_method_stripe[type='radio']:checked::after {
width: 20px !important;
height: 20px !important;
border-radius: 3px;
top: -6px !important;
left: -1px !important;
position: relative;
background-color: #776330 !important;
content: '';
display: inline-block;
visibility: visible;
border: 2px solid #776330 !important;
box-shadow: inset 0 0 0 2px #fff !important;
margin-left: 6px;
}
<input id="payment_method_stripe" type="radio" class="input-radio" name="payment_method" value="stripe" checked="checked" data-order_button_text="">
<label for="payment_method_stripe">Credit / Debit Card</label>
<input id="payment_method_paypal" type="radio" class="input-radio" name="payment_method" value="paypal" data-order_button_text="Proceed to PayPal">
<label for="payment_method_paypal">PayPal</label>
如何在firefox中应用这个样式? Firefox 不显示的问题是什么?
我已经尝试过以下解决方案:
Styling radio button - not work in IE and Firefox How to change style of radio and checkbox input
我认为这段代码适合你。
.checkbox {
position: relative;
padding-left: 30px;
margin-right: 20px;
}
.checkbox input {
width: 0;
height: 0;
position: absolute;
}
.checkbox span {
width: 20px;
height: 20px;
border-radius: 3px;
position: absolute;
left: 0;
top: -1px;
background-color: #fff;
content: '';
display: inline-block;
visibility: visible;
border: 2px solid #776330;
box-sizing: border-box;
}
.checkbox span::after {
position: absolute;
content: '';
left: 2px;
top: 2px;
width: 12px;
height: 12px;
background-color: #776330;
display: none;
}
.checkbox input:checked ~ span::after {
display: block;
}
<label class="checkbox" for="payment_method_stripe">
<input id="payment_method_stripe" type="radio" class="input-radio" name="payment_method" value="stripe" checked="checked" data-order_button_text="">
<span></span>
Credit / Debit Card
</label>
<label class="checkbox" for="payment_method_paypal">
<input id="payment_method_paypal" type="radio" class="input-radio" name="payment_method" value="paypal" data-order_button_text="Proceed to PayPal">
<span></span>
PayPal
</label>
我喜欢 Sato 的回答,但您也可以将其添加到您的 CSS:
input[type='radio'] {
-moz-appearance: initial !important;
}
我会尽量避免在您的 CSS 中使用 !important
,这不是一个好的习惯。我认为如果您将它从您的代码中删除,您可能会从我的代码片段中删除它。