是否可以将图像放入输入类型 =“复选框"? [英] is it possible put image in input type="check box"?

查看:26
本文介绍了是否可以将图像放入输入类型 =“复选框"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在复选框的背景上放一张图片&我的 html 代码中的单选框,但它不起作用,但它适用于其他表单属性.

i want to put an image on the background of check box & radio box in my html code but it's not work but it's work on other form property.

推荐答案

我找到了如何将图像提供给 checkbox &单选按钮,纯CSS.

I found the way how give image to checkbox & radio button with pure css.

HTML

<input type='checkbox' name='thing' value='valuable' id="thing"/><label for="thing"></label>

CSS

input[type=checkbox] {
    display:none;
}

input[type=checkbox] + label {
    background: #999;
    height: 16px;
    width: 16px;
    display:inline-block;
    padding: 0 0 0 0px;
}

input[type=checkbox]:checked + label {
    background: #0080FF;
    height: 16px;
    width: 16px;
    display:inline-block;
    padding: 0 0 0 0px;
}

查看更多http://css-tricks.com/the-checkbox-hack/ ,

https://gist.github.com/592332

这篇关于是否可以将图像放入输入类型 =“复选框"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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