【问题标题】:Mosaic Image Gallery in CSSCSS 中的马赛克图片库
【发布时间】:2011-10-10 17:51:31
【问题描述】:

我想用纯CSS做一个马赛克画廊,但是我想不出“逻辑端”,我需要一个实际的例子。

你能指导我吗?

见过this example,但是不明白怎么实现。

这是我需要的示例:http://tmv.proto.jp/

我想要一个非 jQuery 解决方案。

【问题讨论】:

标签: html css image gallery


【解决方案1】:

首先,制作一些 div 作为列。然后你使用 css 给它们一个宽度(流体的百分比,固定的 px)并将它们向左浮动。 其次,在 css 中为所有图像设置 100% 的宽度,并将它们分布在列中。

示例(未经测试):

HTML:

<div class='col'>
    <img />
    <img />
    <img />
</div>

<div class='col'>
    <img />
    <img />
    <img />
</div>

CSS:

.col{
    width:50%;
    float:left;
}

img{
    width:100%;
}

【讨论】:

  • 你好,Jcubed!感谢您的入场。有用!但是,如果可能的话,你可以告诉我在 foreach(php) 上应用它的逻辑吗?如果我有正确的逻辑,我可以编写代码。
  • foreach(images as i=>image){ divs[i%Number_Divs][]=image;然后使用另一个 foreach 回显 div。希望对您有所帮助。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-08-28
  • 2017-11-20
  • 1970-01-01
  • 2021-01-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多