html - 为什么我的内联不起作用?

标签 html css flexbox

下面是一个 HTML 代码,但是 display:inline 不工作。我不明白为什么。但是 display:flex, display: -webkit-box;, display: -webkit-inline-box; , display: inline -flex; 工作正常;

当我在类位置上使用 display:inline

enter image description here

当我使用 display:flexdisplay: -webkit-box;display: -webkit-inline-box;display: inline-flex; 在类位置

enter image description here

HTML代码如下:

<div class="form-group col-lg-12" style="padding: initial;">
<label class="control-label col-sm-12">Sample type :
</label>
<br>
<div class="col-sm-12 position">
 <div style="margin-right: 15px;">
 <label class="radio-inline">
<input type="radio" id="tee" name="qpd_type" value="5" checked >Type 1 
</label><br/>
</div>
<div>
<label class="radio-inline">
<input type="radio" id="cia" name="qpd_type" value="2" >Type 2
</label>    
       </div>
   </div>


</div>

谁能帮我弄清楚为什么我不能使用 display:inline。谢谢。

最佳答案

试试这个...

删除 <br />从您的代码中标记。

.radio-style {
  margin-right: 15px;
  display: inline;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="form-group col-lg-12" style="padding: initial;">
  <label class="control-label col-sm-12">Sample type :
  </label>
  <br>
  <div class="col-sm-12  position">
    <div class="radio-style">
      <label class="radio-inline">
        <input type="radio" id="tee" name="qpd_type" value="5" checked>Type 1
      </label>
    </div>
    <div class="radio-style">
      <label class="radio-inline">
        <input type="radio" id="cia" name="qpd_type" value="2">Type 2
      </label>
    </div>
  </div>
</div>

此外,只需将两个 radio 放在同一个 div 中即可。你不需要任何额外的 CSS。 :)

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="form-group col-lg-12" style="padding: initial;">
  <label class="control-label col-sm-12">Sample type :
  </label>
  <br>
  <div class="col-sm-12  position">
    <div>
      <label class="radio-inline">
        <input type="radio" id="tee" name="qpd_type" value="5" checked>Type 1
      </label>
      <label class="radio-inline">
        <input type="radio" id="cia" name="qpd_type" value="2">Type 2
      </label>
    </div>
  </div>
</div>

关于html - 为什么我的内联不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39825935/

相关文章:

Javascript 隐藏/显示图层

html - Bootstrap 布局内容表单元素超出列

css - 子导航与最长的子项一样长

javascript - 链接到 index.html 中的 Css 和 js 文件时出错

javascript - 禁止在浏览器中显示 .css 和 .js 文件内容

css - Flexbox:如何在列上组合百分比、像素和剩余高度?

html - 如何删除内联/内联 block 元素之间的空间?

html - 开始我的第一个元素(寻找批评、一般提示、仇恨)

html - 使幻灯片背景透明

javascript - 如何仅使用 HTML、JS 和 CSS 创建自定义文件上传