【发布时间】:2014-07-03 16:21:00
【问题描述】:
如何增加单选按钮的大小?
我知道有很多这样的问题,我浏览了答案并尝试实施它们,但没有任何效果。
以下是我尝试过的一些链接。
http://ryanfait.com/resources/custom-checkboxes-and-radio-buttons/
谁能给我推荐一个可行的例子。谢谢。
【问题讨论】:
标签: javascript html css
如何增加单选按钮的大小?
我知道有很多这样的问题,我浏览了答案并尝试实施它们,但没有任何效果。
以下是我尝试过的一些链接。
http://ryanfait.com/resources/custom-checkboxes-and-radio-buttons/
谁能给我推荐一个可行的例子。谢谢。
【问题讨论】:
标签: javascript html css
这是一个非常基本的例子:http://jsfiddle.net/yrshaikh/uu47Z/
HTML
<form action="/html/codes/html_form_handler.cfm" method="get">
<input type="radio" name="preferred_color" value="Red" class="red" /> Red<br />
<input type="radio" name="preferred_color" value="Blue" /> Blue<br />
<input type="radio" name="preferred_color" value="Green" /> Green<br />
</form>
CSS
input[type=radio] {
margin: 1em 1em 1em 0;
transform: scale(3, 3);
-moz-transform: scale(3, 3);
-ms-transform: scale(3, 3);
-webkit-transform: scale(3, 3);
-o-transform: scale(3, 3);
}
生产
【讨论】:
如果你不想改变比例,你可以使用 CSS 来创建自定义样式(以复选框为例)。这样做的好处是您不再局限于控件的特定于浏览器的外观和感觉。
HTML
<input type='checkbox' />
CSS
input[type=checkbox]{
position:relative;
margin:5px;
}
input[type=checkbox]:before{
position:absolute;
height:30px;
width:30px;
top:-5px;
left:-5px;
border:2px solid grey;
content:'';
background:white;
border-radius:100%;
}
input[type=checkbox]:after{
position:absolute;
display:none;
height:15px;
width:15px;
top:5px;
left:5px;
content:'';
background:grey;
border-radius:100%;
}
input[type=checkbox]:checked:after{
display:block;
}
【讨论】:
您可以只使用 CSS 缩放功能。
h1 {
zoom:200%
}
<h1><input type="radio"></h1>
【讨论】: