我坚持了一段时间。我在模态窗口中有一堆输入来创建一个季节。但它仍然没有响应(在较小的屏幕上看起来很糟糕)。
这两个按钮也应位于井的右侧。我试过像“拉右”类或“向左浮动”和绝对位置之类的东西但是它们总是穿过灰色背景。我该如何解决这个问题?
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3 class="pull-left">Seasons</h3>
</div>
<div class="modal-body" style="position: relative;">
<div class="well">
<div class="row" style="width: 80%; margin: 0;">
<div class="col-sm-6">
<span class="bold">Season name</span>
<input type="text" placeholder="e.g. High season">
</div>
<div class="col-sm-3">
<span class="bold">From</span>
<input type="date" style="font-size: 1.23rem; display: inline-block;">
</div>
<div class="col-sm-3">
<div style="margin-left: 40px;">
<span class="bold">To</span>
<input type="date" style="font-size: 1.23rem;display: inline-block;">
</div>
</div>
</div>
<br>
<button type="button" class="btn btn-default" data-dismiss="modal" style="position: absolute; right: 50px;">Close</button>
<button type="button" class="btn btn-primary" style="position: absolute; right: 20px;">Save</button>
</div>
</div>
</div>
在线代码转到此处:http://www.bootply.com/ojhdwC4y4x#
答案 0 :(得分:2)
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
Launch demo modal
</button>
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3 class="pull-left">Seasons</h3>
</div>
<div class="modal-body">
<div class="well">
<div class="input-group">
<input type="text" class="form-control" placeholder="Season name" aria-describedby="basic-addon1">
</div>
<div class="input-group">
<input type="text" class="form-control" placeholder="From" aria-describedby="basic-addon1">
</div>
<div class="input-group">
<input type="text" class="form-control" placeholder="To" aria-describedby="basic-addon1">
</div>
</div>
<br>
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save</button>
</div>
</div>
</div>
</div>
我认为它是由<span>
标记之前的<input>
标记引起的。让我们尝试上面的代码,改为使用bootstrap输入
结果:
答案 1 :(得分:1)
<div class="row" style="width: 80%; margin: 0;">
<div class="col-sm-6">
<span class="bold">Season name</span>
<input class="form-control" type="text">
</div>
<div class="col-sm-3">
<span class="bold">From</span>
<input class="form-control" type="date">
</div>
<div class="col-sm-3">
<span class="bold">To</span>
<input class="form-control" type="date">
</div>
</div>
如何更改默认的bootstrap样式?
答案 2 :(得分:1)
对于按钮,您应该使用modal-footer
,例如described here。对于响应代码,请尝试以下方法:
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
Launch demo modal
</button>
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3 class="pull-left">Seasons</h3>
</div>
<div class="modal-body">
<div class="well">
<div class="row">
<div class="col-sm-5">
<span class="bold">Season name</span>
<input type="text">
</div>
<div class="col-sm-3">
<span class="bold">From</span>
<input type="date" style="font-size: 1.23rem;">
</div>
<div class="col-sm-3">
<span class="bold">To</span>
<input type="date" style="font-size: 1.23rem;">
</div>
</div>
</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</button>
</div>
</div>
</div>
</div>
请注意,模态组件具有限制大小,行定义了一些边距,但原生HTML 5日期不能很好地适应井组件。因此,您可以从&#34;季节名称&#34;中删除一列。如果你有更多的元素,我建议将它们分成多行。