为什么input [type = checkbox]不允许CSS? [英] Why does input[type=checkbox] not allowing CSS?

查看:101
本文介绍了为什么input [type = checkbox]不允许CSS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找到直接CSS来申请复选框。但是我只能找到样式复选框或单选按钮的技巧。与 input [type = button] [type = text] 不同,为什么复选框或单选按钮不允许本地

I am trying to find direct CSS to apply for checkbox. But I could only find the hacks for styling checkbox or radio button. Unlike input[type=button] or [type=text], why would checkbox or radio button not allow the native CSS styles?

推荐答案

您不能直接设置复选框或单选框的样式。由浏览器设置样式。如果要进行一些自定义,则需要将其隐藏,并通过伪元素(例如:before /:after)对其进行样式设置,或者仅使用span等。

You can't directly style checkbox or radio input. It's styled by browser. If you want to do some customization, you need to hide it, and style it through pseudo element like :before/:after or just use a span etc..

此处都是简单的示例: https://www.w3schools.com/howto/howto_css_custom_checkbox.asp

Here are som simple examples: https://www.w3schools.com/howto/howto_css_custom_checkbox.asp

这篇关于为什么input [type = checkbox]不允许CSS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆