【问题标题】:Missing <div>s on Forms Bootstrap 4表单 Bootstrap 4 上缺少 <div>
【发布时间】:2017-11-08 00:42:29
【问题描述】:

我刚刚使用 Bootstrap 4 开始一个新的表单页面(第一次)。如果我在复选框中添加一个关闭,它会破坏表单。啊?!

我错过了什么吗?

有错误消息要求提供更多详细信息,但我认为我的问题涵盖了它:为什么关闭表单会破坏表单?

https://codepen.io/DennisJM/pen/EbgpwR

<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-
  to-fit=no">

<!-- Bootstrap CSS -->
<link rel="stylesheet" 
 href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-
 alpha.6/css/bootstrap.min.css" integrity="sha384-
 rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" 
 crossorigin="anonymous">
</head>
<body>
<div class="container-fluid">
<h3><p class="text-center text-white pt-2 pb-2 pl-0 pr-0" style="background-
   color:#0000FF;">Every Albany County Listing Emailed Instantly*</p></h3>
   <h3><p class="text-center">What do you want in your new home?</p></h3>

<div class="container-fluid">
<form> 
<div class="form-group">  
<div class="row">
<div class="col" style="background-color:orange;">
<p class="text-right"> Bedrooms?</p>
</div>

<div class="col" class="form-check form-check-inline" style="background-
 color:pink;">
<label class="form-check-label">
<input type="checkbox" class="form-check-input" name="Bedroom2" value="1"> 1
</label>      


<div class="form-check form-check-inline">
<label class="form-check-label">
<input type="checkbox" class="form-check-input" name="Bedroom2" value="2"> 2
</label>


<div class="form-check form-check-inline">
<label class="form-check-label">
<input type="checkbox" class="form-check-input" name="Bedroom2" value="3"> 3
</label>



<div class="form-check form-check-inline">
<label class="form-check-label">
<input type="checkbox" class="form-check-input" name="Bedroom2" value="4"> 4
</label>
</div>
</form>
</div>
</div>
<!-- jQuery first, then Tether, then Bootstrap JS. -->
  <script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" 
   integrity="sha384-
   A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" 
  crossorigin="anonymous"></script>
  <script 

  src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" 
  integrity="sha384-
  DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" 
  crossorigin="anonymous"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-
  alpha.6/js/bootstrap.min.js" integrity="sha384-
  vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" 
  crossorigin="anonymous"></script>
 </body>
 </html>

【问题讨论】:

  • 你没有关闭

标签: html twitter-bootstrap forms


【解决方案1】:

这可能取决于您关闭标签的方式。这可能是因为&lt;input&gt; 标签是自动关闭的。换句话说,

错误:

<input type="checkbox" value="4">4</input>

正确(两者):

<input type="checkbox" value="4" />4
<input type="checkbox" value="4">4

可见的数字 4 是页面的一部分,而不是 &lt;input&gt; 标记内容的一部分。

更多详情请查看此答案:Are (non-void) self-closing tags valid in HTML5?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-05-18
    • 1970-01-01
    • 1970-01-01
    • 2018-08-14
    • 1970-01-01
    • 2019-04-16
    • 1970-01-01
    相关资源
    最近更新 更多