I'm trying to display some pictures. All of them have the same width but different height. I'm trying to do something like:

我正在尝试显示一些照片。所有这些都具有相同的宽度但不同的高度。我正在尝试做类似的事情:

Every picture's class name is pic

每张图片的类名都是pic

<img class = "pic" src = .... />

In the stylesheet I specified the float:left attribute:

在样式表中我指定了float:left属性:

.pic{
    float:left
}

The end result isn't the one expected while every row is vertically aligned after the highest div from the row before:

最终结果不是预期的结果,而每行在前一行的最高div之后垂直对齐:

Is there a way to solve my problem in pure cross browser css?

有没有办法在纯交叉浏览器CSS中解决我的问题?

3 个解决方案

#1


5

You can do this with no extra markup with CSS3 column-count, assuming you at least have a single containing element.

假设您至少有一个包含元素,那么您可以在没有CSS3列数的额外标记的情况下执行此操作。

Demo: http://jsfiddle.net/ThinkingStiff/NcxPr/

HTML:

<div id="container">
<img class="image" src="http://farm1.staticflickr.com/205/494701000_744cc3a83a_z.jpg" />
<img class="image" src="http://farm5.staticflickr.com/4028/4287569889_f6a4fca31b_z.jpg" />
<img class="image" src="http://farm3.staticflickr.com/2340/2421926504_d8509d0a98_z.jpg" />
<img class="image" src="http://farm1.staticflickr.com/197/503792921_fedf8ba47e_z.jpg" />
<img class="image" src="http://farm2.staticflickr.com/1153/741035029_f394e11a1f_z.jpg" />
<img class="image" src="http://farm7.staticflickr.com/6213/6243090894_8b8dd862cd_z.jpg" />
<img class="image" src="http://farm2.staticflickr.com/1339/1157653249_dbcc93c158_z.jpg?zz=1" />
<img class="image" src="http://farm3.staticflickr.com/2570/4220856234_029e5b8348_z.jpg?zz=1" />
</div>

CSS:

#container {
    column-count: 3;
    column-fill: balance;
    column-gap: 10px;
    width: 330px;
}

.image { 
    display: block;
    margin-bottom: 10px;
    width: 100px;
} 

Output:

更多相关文章

  1. PHP选择具有特定宽度的图像并构建网格
  2. phpstorm取消自动保存并标识修改的文件为星星标记
  3. 纯php文件不加结束标记的好处
  4. JSON解析错误:无法识别的标记'<'处于角度
  5. hibernate(*.hbm.xml)中新添加的字段被标记为红色(找不到)的解决方法
  6. 可以访问Stackoverflow的自动建议标记系统吗?
  7. 使用.after()添加html关闭和打开标记
  8. 具有固定宽度网格的引导程序和应跨越窗口宽度的图像
  9. 如何使用条件if()使用javascript检索带有指定值的选择标记的xml数

随机推荐

  1. [安卓]Android(安卓)Developer Tools(Ecl
  2. Android 二维码开发功能实现(五)-----对z
  3. Android(安卓)AIDL基本步骤
  4. Socket Android手机客户端与PC服务端局域
  5. sscanf函数引起android 5.0卡死,C++中慎用
  6. Android 系统基础
  7. Android之Window类简介
  8. 强烈推荐Android新手的入门学习策略之一,A
  9. Android下添加新的自定义键值和按键处理
  10. Android输入框限制字符长度,字母自动大写