html - CSS label 间距
问题描述
我做了一个radio select,选择器。效果图
radio中间的间距不知道是哪来的, 如果消除间距?代码如下:html
<p class='radio-toolbar'> <input type='radio' name='radios' value='all' checked> <label for='radio1'>从不</label> <input type='radio' name='radios'value='false'> <label for='radio2'>有时</label> <input type='radio' name='radios' value='true'> <label for='radio3'>经常</label></p>
css
<style>.radio-toolbar input[type='radio'] { display:none;}.radio-toolbar>label { display:inline-block; background-color:#ddd; padding:4px ; font-family:Arial; font-size:16px;}.radio-toolbar label:first-of-type{ border-radius: 12px 0 0 12px;}.radio-toolbar label:last-of-type{ border-radius: 0 12px 12px 0;}.radio-toolbar input[type='radio']:checked + label { background-color:#bbb;} </style>
已经采纳长空的答案,其余答案也是对的,最终解决方案如下
.radio-toolbar{ font-size: 0;}
问题解答
回答1:inline-block的换行符啦,我一般是设置font-size:0来解决。详细的点这
回答2:<p class='radio-toolbar'><input type='radio' name='radios' value='all' checked><label for='radio1'>从不</label><input type='radio' name='radios'value='false'><label for='radio2'>有时</label><input type='radio' name='radios' value='true'><label for='radio3'>经常</label> </p>
把代码都写在一起 不要有空格 就没有间隙了
回答3:.radio-toolbar>label 加个float: left; 父元素高度为0,你再清除浮动overflow: hidden;
相关文章:
1. windows误人子弟啊2. 冒昧问一下,我这php代码哪里出错了???3. MySQL主键冲突时的更新操作和替换操作在功能上有什么差别(如图)4. python - linux怎么在每天的凌晨2点执行一次这个log.py文件5. 数据库 - Mysql的存储过程真的是个坑!求助下面的存储过程哪里错啦,实在是找不到哪里的问题了。6. 实现bing搜索工具urlAPI提交7. mysql优化 - MySQL如何为配置表建立索引?8. 如何用笔记本上的apache做微信开发的服务器9. 我在网址中输入localhost/abc.php显示的是not found是为什么呢?10. 关于mysql联合查询一对多的显示结果问题
