【发布时间】:2018-04-18 22:41:00
【问题描述】:
我正在使用bootstrap-sass 在垂直堆栈中布局一些div 元素。但是,当视口高于 md 大小时,div 元素溢出并产生垂直滚动条时,我遇到了问题。
演示 https://nyc3.digitaloceanspaces.com/bingo-assets/index.html
这是我的grid.scss 文件:
@import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap/variables";
@import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap/mixins";
@import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap/grid";
@import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap/responsive-utilities";
.row {
@include make-row();
}
#content {
@include container-fixed;
}
#promo-header {
@include make-sm-column(12);
}
#subscribe {
@include make-sm-column(12);
}
#video {
@include make-sm-column(12);
}
#factoid {
@include make-sm-column(12);
}
下面是 HTML:
<div id="content">
<div class="row">
<div id="promo-header">
<img width="100%" src="/images/promo.jpg">
</div>
<div id="subscribe">
<h2>Simply enter your details for a chance to win!</h2>
<form name="subscribe">
<div>
<label>Firstname</label>
<input type="text" name="firstname" />
</div>
<div>
<label>Surname</label>
<input type="text" name="surname" />
</div>
<div>
<label>Email</label>
<input type="text" name="email" />
</div>
<div>
<label>Telephone</label>
<input type="text" name="telephone" />
</div>
<div>
<label>Postcode</label>
<input type="text" name="postcode" />
</div>
<div>
<label>Have you seen this product on TV?</label>
<select name="question">
<option value>Please Select</option>
<option value="Y">Yes</option>
<option value="N">No</option>
</select>
</div>
<button class="btn">Get Your Coupon</button>
<small>Please note: Only one coupon available per person and only one email address allowed per person. Coupon valid 02.10.17 - 31.03.18. Redeemable by UK residents 18+ only in participating stores only.</small>
</form>
</div>
<div id="video">
<div id="video-container">
<iframe src="https://www.youtube.com/embed/ZZa7Kgo0apA" frameborder="0" allowfullscreen></iframe>
</div>
<div id="description">
<h2>Video Title</h2>
<p>Do you want to cook amazing meals?</p>
</div>
</div>
<div id="factoid">
<h2>Celebrity dietician Lucy Jones and Princes are working together to show families how they can eat well with canned fish.</h2>
<p>Did you know our fillers are:</p>
<ul>
<li>High in protein</li>
<li>Low in saturated fat</li>
<li>A quick and easy lunch</li>
</ul>
<a href="#" class="btn">Learn More</a>
</div>
</div>
</div>
我在每个div 周围设置了一个红色边框。以下是它在中小型视口上的样子:
【问题讨论】:
-
这里没什么可看的,如果我们可以对代码进行故障排除并查看应用了哪些样式,这将更有帮助,因为这是确定问题的地方。您能否生成一个指向可以检查和探索 DOM 的实时环境的链接?
-
没有应用更多样式。我在调试时将它们全部删除,除了网格样式。唯一应用的样式是您在上面看到的样式。没有现场版。我看看能不能在网上弄点东西。
-
这将是理想的 - 像检查相关元素时一样查看 rendered/processed 样式。
-
我上传了一个演示。
-
似乎媒体查询被击中并使 div 的宽度为 100%。不知道为什么。
标签: css twitter-bootstrap twitter-bootstrap-3 sass