css - 如何定位输入类型单选框和复选框内联位置?

标签 css html

我想定位我的单选按钮和checkboxes内联位置我已经使用了这个css代码但是它没有工作

CSS

.checkbox-inline, .radio-inline {
    cursor: pointer;
    display: inline-block;
    font-weight: 400;
    margin-bottom: 0;
    padding-left: 20px;
    position: relative;
    vertical-align: middle;

}
input[type=radio] {
     margin-left: -20px;
    position: absolute;
}

html

<div>
 <label> <b>carburant: </b><span>(*)</span></label>
  <label class ='radio-inline'><input type='radio' name='carburant' value=1 checked> AA</label>
<label><input class ='radio-inline' type='radio' name='carburant' value=2> BB</label>
<label><input class ='radio-inline' type='radio' name='carburant' value=3> CC</label>
<label><input class ='radio-inline' type='radio' name='carburant' value=4> DD</label>
</div><br />




<div>
     <label> <b>city: </b><span>(*)</span></label>
      <label class ='checkbox-inline'><input type='checkbox' name='carburant' value=1 checked> AA</label>
    <label><input class ='checkbox-inline' type='checkbox' name='carburant' value=2> BB</label>
    <label><input class ='checkbox-inline' type='checkbox' name='carburant' value=3> CC</label>
    <label><input class ='checkbox-inline' type='checkbox' name='carburant' value=4> DD</label>
    </div><br />

我没有使用 twitter bootstrap,我正在使用 html5。 我想在同一行显示我的按钮。

谢谢。

最佳答案

你的问题不是很清楚,但我想你想内联你的单选按钮,我希望下面的解决方案对你有所帮助。

.checkbox-inline, .radio-inline {
    cursor: pointer;   
    font-weight: 400;
    margin-bottom: 0;
    padding-left: 20px;
}
<div >
 <label> <b>carburant: </b><span>(*)</span></label>
  <label class ='radio-inline'><input type='radio' name='carburant' value=1 checked> AA</label>
<label><input class ='radio-inline' type='radio' name='carburant' value=2> BB</label>
<label><input class ='radio-inline' type='radio' name='carburant' value=3> CC</label>
<label><input class ='radio-inline' type='radio' name='carburant' value=4> DD</label>
</div><br />

关于css - 如何定位输入类型单选框和复选框内联位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32475551/

相关文章:

javascript - 如何使用纯 JS 通过我从中检索内容的 json 中的特定值过滤 HTML 菜单?

javascript - 如何从 JavaScript 获取图像值并使用 php 提交到 mysql 表

css - Gulp-compass 压缩 sass 不工作

php - 无法在 codeigniter 3 中加载 css 文件

javascript - 如何使用 Javascript 在 Safari HTML5 播放器中使用 iOS 锁屏上一个/下一个播放器按钮

javascript - 如何禁用谷歌 360 旅游滚动缩放?

html - div 中的表? IE7 兼容性问题 - 寻找资源来扩展有关如何处理 IE7 问题的知识

jquery - 如何在 jQuery 中获取背景图像大小?

html - Dropotron 左填充不起作用

javascript - 通过 Google Chrome 扩展从注入(inject)的 html 调用带有 ng 指令的函数