【发布时间】:2017-05-11 00:14:48
【问题描述】:
为教育目的创建一个网站,但我遇到了网格/列高问题。
这是我要复制的网站图片: Click me
这是我目前得到的:Click me
我的问题是,在第一行我有两列 (col-sm-6),在第一列我嵌套了另一行并在其中创建了 2 个额外的列。但是,第二列似乎比第一列高。我尝试调整 img 大小,但它失去了我需要的响应能力。
希望有人理解我想说的话,我对 Web 开发真的很陌生。我希望有人可以帮助我。 :(
请参考随附的图片来验证问题。谢谢。
我的代码 -
HTML:
<!-- start portfolio-content -->
<section class="portfolio-content">
<div class="row" id="port-first-row">
<div class="col-sm-6" id="port-first-col">
<div class="row">
<div class="col-12">
<img src="images/others/large/BridalPlannerHeader.jpg" alt="image"/>
</div> <!-- end col-12 -->
<div class="col-12">
<img src="images/others/large/video-home.jpg" alt="video" />
</div> <!-- end col-12 -->
</div> <!-- end row -->
</div> <!-- end port-first-col -->
<div class="col-sm-6" id="port-second-col">
<img src="images/home/medium/KC_phuket-thailand-wedding-photographer_0061.jpg" alt="image" />
</div> <!--end port-second-col -->
</div> <!-- end port-first-row -->
<div class="row" id="port2-second-row">
<div class="col-sm-6" id="port2-first-col">
<img src="images/others/large/Phuket_view.jpg" alt="phuket" />
</div> <!-- end col-sm-6 -->
<div class="col-sm-6" id="port2-second-col">
<img src="images/others/large/Julie+Andrew_darinimages-409.jpg" alt="julie" />
</div> <!-- end col-sm-6 -->
</div> <!-- end port-second-row -->
</section> <!-- end portfolio-content -->
CSS/SASS:
.portfolio-content {
max-width: 100%;
}
img {
width: 100%;
}
.col-sm-6 {
padding: 0;
}
#port-first-row {
max-width: 100%;
margin: 0;
}
#port2-second-row {
max-width: 100%;
margin: 0;
}
【问题讨论】:
-
引导程序中没有
col-12类 -
尝试使用 bootstrap 预定义的
class="img-responsive"图像。 -
我认为 col-12 让你使用 div 的整个长度还是占据所有 12 个空间?唔。回家后让我试试 img-responsive 。我会回复你的,谢谢你回答顺便说一句。 :)
-
填充整个行的宽度,你可以使用任何视口宽度
col-xs-12 -
我明白了.. img-responsive 类怎么样?即使包含它的 div 具有未定义的宽度/高度,它会起作用吗?我很想尝试一下,但我还没回家。 :(
标签: twitter-bootstrap css grid alignment