我想拥有收音机功能(M或F)。
但是我不能使用它。 (它无法实现我想要的样式)
<input type="radio" id="Member_Sex_boy" class="btn btn-default" onclick="ChangeColor_boy();" name="Member_Sex" VALUE="1" CHECKED >MAN</input>
图片是使用
<input type="radio"...
https://goo.gl/RCaMgP
但是我想要这张照片。 (使用
<button type="radio"...
或<label type="radio"...
)https://goo.gl/37FzCF
但是,如果它是
<button type="radio"...
:当我按收音机时,它将自动提交表单。并且,如果它是
<label type="radio"...
:当我按下“提交”按钮时,它无法为数据库发送数据。所以我想用
radio
实现button
。(例如,
<button type="button"...
可以广播项目)(抱歉,我无法发布图片。)
最佳答案
只需使用css即可完成,只需要一点创意即可;)
input[name='sex'] {
-webkit-appearance: none;
-moz-appearance: none;
-o-appearance: none;
-ms-appearance: none;
appearance: none;
background: none;
border: none;
outline: none;
}
input[name='sex']:after {
display: inline-block;
text-align: center;
content: attr(value);
padding: 10px 0;
width: 40px;
border: solid 1px;
border-radius: 5px;
}
input[name='sex']:checked:after {
background: #000;
color: #fff;
}
<input type="radio" name="sex" value="f" checked />
<input type="radio" name="sex" value="m" />