[英]How do I get my images to responsively resize with shuffle.js?
I am using shuffle.js on my homepage and I am trying to get my images to responsively resize like in this demo the developer posted here . 我在我的主页上使用shuffle.js,并且试图像开发人员在此处发布的此演示中那样,使我的图像响应地调整大小。
Right now I am just using media queries as a workaround, but the results are far from ideal. 现在,我只是将媒体查询用作解决方法,但结果远非理想。
Note: the grid is already responsive, what I would like to see is for the images themselves to resize as well. 注意:网格已经响应,我想看到的是图像本身也要调整大小。
You must use a CSS Grid to have a nice responsive combined with Shuttle. 您必须使用CSS网格才能与Shuttle结合使用,从而具有良好的响应能力。
Note the classes .span3 and .m-span3 on element 注意元素上的类.span3和.m-span3
The example of your link is using Bootstrap v2.3.2. 链接的示例使用的是Bootstrap v2.3.2。 You can use the Twitter Bootstrap 3 which has better semantic as well, or any other grid system.
您可以使用语义也更好的Twitter Bootstrap 3或任何其他网格系统。
http://getbootstrap.com/examples/grid/ http://getbootstrap.com/examples/grid/
If you use Bootstrap 3, add the class xs-col-12 and col-4 like so: 如果使用Bootstrap 3,则添加类xs-col-12和col-4,如下所示:
<div id="grid" class="shuffle">
<div onclick="window.location.href = 'IEMA.html'" class="xs-col-12 col-4 item Aston shuffle-item filtered ">
<div id="overlay">ASTON</div>
</div>
<div onclick="window.location.href = 'Aston.html'" class="xs-col-12 col-4 item Aston shuffle-item filtered">
<div id="overlay">IEMA</div>
</div>
</div>
If you don't want to include Bootstrap, you can add http://996grid.com/ with same way, using class .grid_4 shoud be fine. 如果您不想包含Bootstrap,则可以使用.grid_4类以相同的方式添加http://996grid.com/ 。
Update 更新
I can make some adjusts for your page have a better grid with shuffle changing for this style for your items when lower than 690px:
当您的项目低于690px时,我可以为您的页面进行一些调整,以使您的项目的样式更改为随机更改:
@media only screen and (max-width: 690px)
.item {
background-position: center;
background-repeat: no-repeat;
background-size: cover;
height: 223px;
width: 100%;
}
}
To clarify my question: I'm not looking to resize the grid, that already works.
为了澄清我的问题:我不打算调整网格大小,这已经可以了。
You have already a responsive class attached to the image's container, 您已经在图像容器上附加了一个响应式类,
I want the images themselves to resize.
我希望图像自己调整大小。
then you only need to add max-width:100%
to the img
element. 那么您只需要将
max-width:100%
到img
元素。
In my case : 就我而言:
<figure class="xs-col-12 col-4 picture-item" data-title="The Magic Box">
<div class="aspect aspect--16x9">
<div class="aspect__inner">
<img style="max-width:100%" src="/the-magic-box.png" />
</div>
</div>
<figcaption>The Magic Box</figcaption>
</figure>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.