我正在使用 Twitter Bootstrap ,特别是表单和模式。我的主表单位于模态主体内,但提交按钮需要位于模态页脚中。这意味着我必须关闭一个 div 并打开一个新的 inside 表单,如下所示。
<div class="modal-body">
<form>
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail1" placeholder="Enter email">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</form>
</div>
供引用,这是模态的样子:
我很好奇这是否是正确的做法,还是应该采用另一种方法(我所能想到的就是将表单标签放在模态主体标签之外)。
最佳答案
移动<form>
标签,以便它包含整个 modal-body
分区
不要使用不正确的标签嵌套。
<form>
<div class="modal-body">
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail1" placeholder="Enter email">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</form>
关于html - 在关闭 div 后结束表单,不好的做法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28726139/