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'>經(jīng)常</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>
已經(jīng)采納長空的答案,其余答案也是對的,最終解決方案如下
.radio-toolbar{ font-size: 0;}
問題解答
回答1:inline-block的換行符啦,我一般是設(shè)置font-size:0來解決。詳細(xì)的點這
回答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'>經(jīng)常</label> </p>
把代碼都寫在一起 不要有空格 就沒有間隙了
回答3:.radio-toolbar>label 加個float: left; 父元素高度為0,你再清除浮動overflow: hidden;
相關(guān)文章:
1. 關(guān)docker hub上有些鏡像的tag被標(biāo)記““This image has vulnerabilities””2. docker鏡像push報錯3. Docker for Mac 創(chuàng)建的dnsmasq容器連不上/不工作的問題4. javascript - 在 model里定義的 引用表模型時,model為undefined。5. 利用IPMI遠(yuǎn)程安裝centos報錯!6. node.js - mongodb查找子對象的名稱為某個值的對象的方法7. 運行python程序時出現(xiàn)“應(yīng)用程序發(fā)生異常”的內(nèi)存錯誤?8. html5和Flash對抗是什么情況?9. phpstudy8.1沒集成mysql-front10. 前端 - @media query 使用出現(xiàn)的問題?

網(wǎng)公網(wǎng)安備