简体   繁体   English

屏幕为xs时使用列的Bootstrap Img Align Issue

[英]Bootstrap Img Align Issue using columns when screen is xs

I have a div that lists screenshots for my software that I'm displaying on a website. 我有一个div,其中列出了我在网站上显示的软件的屏幕截图。 When the screen is big the images align properly. 屏幕较大时,图像会正确对齐。

看到它的图片在大屏幕上正常工作

The problem is when I view it on the phone or change the window size on the computer to collapse the items, there's empty space where it's not being aligned properly for some reason. 问题是当我在电话上查看它或在计算机上更改窗口大小以折叠这些项目时,由于某些原因,没有可用的空白空间。 See Picture below. 请参阅下面的图片。

在此处输入图片说明

Here is the Code on the index page. 这是索引页面上的代码。 In my opinion, everything should work fine without adjustments. 我认为,无需调整,一切都可以正常工作。

Things I've tried: -Removing the container and row classes. 我尝试过的事情:-删除容器和行类。 -Changing the width of the images all the way down to 80%, which even 100% SHOULD work -Adding class="img-responsive" as seen in another thread. -将图像的宽度完全减小到80%,即使100%也应该起作用-添加class =“ img-sensitive”(在另一个线程中看到)。 -Removing margins and padding for the divs the images are in. -删除图像所在的div的边距和填充。

<!-- Screenshots -->
<div id="screenshots">
    <div class="container">
    <br>
        <div class="row text-center"> <!-- Screenshot DIV -->
            <h2>Screenshots<h2>
            <div class="col-md-2 col-xs-6">
                <img src="images/screenshots/dashboard.png" alt="Dashboard SS" class="img-responsive" width="100%" />
            </div>
            <div class="col-md-2 col-xs-6">
                <img src="images/screenshots/lotmanager.png" alt="Lot Manager SS" class="img-responsive" width="100%" />
            </div>
            <div class="col-md-2 col-xs-6">
                <img src="images/screenshots/register.png" alt="Register SS" class="img-responsive" width="100%" />
            </div>
            <div class="col-md-2 col-xs-6">
                <img src="images/screenshots/sell.png" alt="Auction SS" class="img-responsive" width="100%" />
            </div>
            <div class="col-md-2 col-xs-6">
                <img src="images/screenshots/checkout.png" alt="Checkout SS" class="img-responsive" width="100%"/>
            </div>
            <div class="col-md-2 col-xs-6">
                <img src="images/screenshots/samplereceipt.png" alt="Receipt SS" class="img-responsive" width="100%" />
            </div>
        </div><!-- /.Screenshot DIV -->
        <br>
    </div><!-- /.container -->
</div><!-- /.screenshots -->

Any help would be appreciated. 任何帮助,将不胜感激。

您的代码中有一个错误,请检查正确的/h2

 <h2>Screenshots</h2> 

It is due to different height of the images. 这是由于图像的高度不同。 What can u do Set the parent div of the img to the maximum height from the group of the images? 您可以将img的父div设置为图像组中的最大高度吗?

var maxheight;
$('#screenshots .container > div > img').each(function(){
var currHeight = $(this).height();
if(maxHeight < currHeight) {
maxHeight = currHeight;
}
});
if(window.width() < 768) {
$('#screenshots .container > div').hieght(maxHeight);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM