input[type="radio"]的样式可以用通过label来改变样式
//IAH5中的代码 先隐藏radio元素 然后通过编辑label的样式来改变 --》点击label也可以触发radio .page6 input[type='checkbox'] { display: none; } .page6 input[type='checkbox'] + label{ position: absolute; left: 50%; margin-left: -.25rem; width: .5rem; height: .41rem; border: .05rem solid #fff; border-radius: .1rem; background: #fff; } .page6 input[type='checkbox']:checked + label{ background: #ffce0d; }
直接在css中编辑input[input="radio"]的样式在移动端是没有效果的,还是会显示系统默认的样式
-webkit-appearance: none;//消除输入框和按钮的原生外观,在iOS上加上这个属性才能给按钮和输入框自定义样式
另:
移动端页面默认样式重置:
1.-webkit-tap-highlight-color
-webkit-tap-highlight-color:rgba(0,0,0,0);//透明度设置为0,去掉点击链接和文本框对象时默认的灰色半透明覆盖层(iOS)或者虚框(Android)
-webkit-tap-highlight-color:rgba(255,0,0,0.5); //利用此属性,设置touch时链接区域高亮为50%的透明红,只在ios上起作用。android上只要使用了此属性就表现为边框。在body上加此属性,这样就保证body的点击区域效果一致了
2.outline:none
(1)在pc端为a标签定义这个样式的目的是为了取消ie浏览器下点击a标签时出现的虚线。ie7及以下浏览器还不识别此属性,需要在a标签上添加hidefocus="true"
(2)input,textarea{outline:none} 取消chrome下默认的文本框聚焦样式
(3)在移动端是不起作用的,想要去除文本框的默认样式可以使用-webkit-appearance,聚焦时候默认样式的取消是-webkit-tap-highlight-color。看到一些移动端reset文件加了此属性,其实是多余。
3.-webkit-appearance
-webkit-appearance: none;//消除输入框和按钮的原生外观,在iOS上加上这个属性才能给按钮和输入框自定义样式
不同type的input使用这个属性之后表现不一。text、button无样式,radio、checkbox直接消失
4.-webkit-user-select
-webkit-overflow-scrolling:touch;// 局部滚动(仅iOS 5以上支持)
*:not(input,textarea) {
-webkit-touch-callout: none;
-webkit-user-select: none;
}