复选框和单选框与文字水平垂直居中对齐的解决方法


本文摘自PHP中文网,作者小云云,侵删。

checkbox和radio两个标签都是我们经常会用到的,有时候项目中出现了一个checkbox与同一行的文字不能对齐的问题,检查后发现个问题,checkbox和radio两个标签的默认高宽都是13px,而项目中使用的字体大小却是12px,如果将字体调整为14px就不存在这个问题了,于是作者根据网上查到的资料整理了几种解决办法。

先发一下具体的问题情况以及解决后的效果:

11.jpg

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

<html>

<head>

<meta charset="UTF-8">

<style type="text/css">

body{font-size:12px;}

div{float:left;width:110px;}

input{margin:0;padding:0;}

.input1{vertical-align:text-bottom;margin-bottom:-1px;*margin-bottom:-4px;}

.input2{height:13px;vertical-align:text-top;margin-top:0;}

.input3{height:15px;vertical-align:bottom;margin-bottom:-1px;margin-bottom:-2px\9;*margin-bottom:0px;}

.input4{height:14px;vertical-align:top;margin-top:1px;margin-top:0\9;}

.input5{vertical-align:middle;margin-top:-2px;}

.input6{vertical-align:-3px;}

</style>

</head>

<body>

<h2>一般的情况</h2>

<p><input type="checkbox" />复选框&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" />单选框</p>

<div>

<h2>单选框</h2>

<p><input type="radio" class="input1"/>解决方法一</p>

<p><input type="radio" class="input2"/>解决方法二</p>

<p><input type="radio" class="input3"/>解决方法三</p>

<p><input type="radio" class="input4"/>解决方法四phpernote.com</p>

<p><input type="radio" class="input5"/>解决方法五</p>

<p><input type="radio" class="input6"/>解决方法六</p>

</div>

<div>

<h2>复选框</h2>

<p><input type="checkbox" class="input1"/>解决方法一</p>

<p><input type="checkbox" class="input2"/>解决方法二</p>

<p><input type="checkbox" class="input3"/>解决方法三</p>

<p><input type="checkbox" class="input4"/>解决方法四</p>

<p><input type="checkbox" class="input5"/>解决方法五</p>

<p><input type="checkbox" class="input6"/>解决方法六</p>

</div>

</body>

</html>

兼容浏览器:chrome,firefox,ie8,ie7,ie6,safari

阅读剩余部分

相关阅读 >>

jquery怎么判断复选框是否被选中

在div中img,span怎样可以做出垂直居中

html的元素水平垂直居中应该怎么设置

layui如何获取复选框的值以及如何为复选框赋值

dreamweaver插入面板显示为水平插入栏

layui怎么设置复选框

vue v-for的循环复选框默认勾选首个

html的文字图片怎样垂直居中

怎样使用li进行水平排列

复选框和单选框与文字水平垂直居中对齐的解决方法

更多相关阅读请进入《复选框》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...