【发布时间】:2018-02-06 01:07:06
【问题描述】:
我正在尝试在移动视图中使用 Bootstrap 3 创建此设计 (here)。但是,我希望图像彼此相对,例如 this
这是我到目前为止所做的:
HTML:
<div class="container">
<div class="row">
<div class="col-md-6"><img src="http://www.dialhousehotel.com/wp-content/uploads/2017/09/room-5.jpg" alt="Picture of room one" class="img-responsive" width="500px" height="300px"></div>
<div class="col-md-6">
<div class="rooms-photo-text">
<h2><span style="color: #bb9b50;">Cosy<br>
</span></h2>
<p>Our Cosy double rooms are small but perfectly appointed for your stay. Each one has a double bed and views out to the garden from the main house.</p>
<div class="wideSeparatorDark"></div>
</div>
</div>
<div class="clearfix"></div>
<div class="col-md-6 col-md-pull-6"><img src="http://via.placeholder.com/500x300" alt="Picture of room two" class="img-responsive" width="500px" height="300px"></div>
<div class="col-md-6 col-md-push-6">
<div class="rooms-photo-text">
<h2><span style="color: #bb9b50;">Splendid<br>
</span></h2>
<p>Our Splendid rooms are more spacious than the Cosy and located in both the main house and the coach house building. Beautifully appointed with Cotswolds charm.</p>
<div class="wideSeparatorDark"></div>
</div>
</div>
<div class="clearfix"></div>
<div class="col-md-6"><img src="http://via.placeholder.com/500x300" alt="Picture of room three" class="img-responsive" width="500px" height="300px"></div>
<div class="col-md-6">
<div class="rooms-photo-text">
<h2><span style="color: #bb9b50;">Awesome<br>
</span></h2>
<p>Our Awesome rooms are wonderfully comfortable, similar to the Splendid but with stunning views of the village and River Windrush. These truly sumptuous rooms are the perfect place to relax and call ‘home from home’.</p>
<div class="wideSeparatorDark"></div>
</div>
</div>
</div>
</div>
第二个 col-md-6 组之间似乎存在差距。似乎没有修复重叠的列。 密码笔是https://codepen.io/anon/pen/pabRJg
【问题讨论】:
-
你不能像那样搞乱网格系统 - .row 需要只包含 .col 元素,你不能只插入任意其他东西。只需将这 6-of-12 宽列中的两列放入 .row 中,这应该会自动解决您的问题(.row 已经隐式应用了 clearfix。)
-
.clearfix在单个.row中使用超过 12 个时有意用于响应式重置:getbootstrap.com/docs/3.3/css/#grid-responsive-resets
标签: twitter-bootstrap twitter-bootstrap-3