【发布时间】:2019-03-28 07:38:34
【问题描述】:
我现在正在学习网页设计并制作一个模拟网站,我对 bootstrap、css 和 html 非常陌生,不知道我哪里出错了,我开始像一直在做的那样努力这整个早上都没有结果,所以我希望你们能帮助我。我一直在尝试将 div 的文本部分与视频的右侧对齐。我设法把它移到了右边,但没有放在它旁边,所以它都在后台容器内。在我看来,这可能是列的问题,因为视频列一直延伸,我想知道它们是否阻止了最后一个列向上移动。我希望这是有道理的。
我尝试了不同的显示和浮动选项以及分离和混合行,但似乎没有成功。
下面的HTML代码和CSS:
<!--CONTAINER MAIN ABOUT INFO-->
<div class="page-header">
<h2>About Us</h2>
</div>
<div class="container container-about">
<!--VIDEOS-->
<div class="row videos">
<div class="col-md-4 vid1">
<div class="embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item" width="560" height="315" src="https://www.youtube.com/embed/afRUIVxTGls" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
</div>
<div class="col-md-4 vid2">
<div class="embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item" width="560" height="315" src="https://www.youtube.com/embed/NNgRnJIjXM4" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
</div>
<div class="col-md-8 about">
<p><strong>lorem epson etc</p>
</div>
</div>
</div>
<!--END OF MAIN ABOUT INFO-->
CSS
.videos {
display: inline;
}
.about {
float: right;
}
【问题讨论】:
-
Bootsrap 基于 12 列网格布局。您超出了该布局的限制,因此无法正确显示。您需要将 div 的列使用总数减少到 12,以便它按预期工作。最后一个 div 'col-md-8' 占据了 2/3 的空间,像其他的一样减少到 'col-md-4' 就可以了。
标签: html css bootstrap-4