创建一个用于教育目的的网站,但我遇到网格/列高问题。
这是我尝试复制的网站图片: Click me
这是我迄今为止所得到的:Click me
我的问题是,在第一行我有两列(col-sm-6),在第一列我嵌套了另一行,并在其中创建了2个额外的列。但是,第二列似乎比第一列高。我试图调整img大小,但它失去了我需要的响应能力。
希望有人理解我想说的话,我对网络开发并不陌生。我希望有人可以帮助我。 :(
请参阅附带的图片以验证问题。感谢。
我的代码 -
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;
}
答案 0 :(得分:0)
这是一个片段,但我无法理解为什么列之间存在如此巨大的差距。
虽然看https://jsfiddle.net/xeen9s7y/ - 但效果很好。
我已将border: solid 1px red;
添加到图片中以获得更好的视觉控制。
img {
width: 100%;
height: 100%;
border: solid 1px red;
}
.imgcont {
height: 25vw;
padding: 1px;
}
.imgcont2 {
height: 50vw;
padding: 1px;
}
&#13;
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<section class="portfolio-content">
<div class="row" id="port-first-row">
<div class="col-xs-6" id="port-first-col">
<div class="row">
<div class="col-xs-12 imgcont">
<img src="//placehold.it/200x150/2255EE" alt="image"/>
</div> <!-- end col-12 -->
<div class="col-xs-12 imgcont">
<img src="//placehold.it/200x150/2255EE" alt="video" />
</div> <!-- end col-12 -->
</div> <!-- end row -->
</div> <!-- end port-first-col -->
<div class="col-xs-6 imgcont2" id="port-second-col">
<img src="//placehold.it/200x150/2255EE" alt="image" />
</div> <!--end port-second-col -->
</div> <!-- end port-first-row -->
<div class="row" id="port2-second-row">
<div class="col-xs-6 imgcont" id="port2-first-col">
<img src="//placehold.it/200x150/2255EE" alt="phuket" />
</div> <!-- end col-sm-6 -->
<div class="col-xs-6 imgcont" id="port2-second-col">
<img src="//placehold.it/200x150/2255EE" alt="julie" />
</div> <!-- end col-sm-6 -->
</div> <!-- end port-second-row -->
</section> <!-- end portfolio-content -->
&#13;