轻松定位图像,其高度是其他图像的两倍
我想制作一个包含 8 个图像的页面,如下所示:
img1 img2 img3
img4 img5 img8
img6 img7 img8
如您所见,“img8”的高度是所有其他图像的两倍。
我如何在CSS中做到这一点?
I want to make a page with 8 images like this:
img1 img2 img3
img4 img5 img8
img6 img7 img8
As you can see "img8" is double as tall as all the other images.
How do I do this in css?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
正如斯科特所说,有不同的方法可以做到这一点。如果您的图像具有特定的宽度和高度,请查看我的示例是否适合您:
http://jsfiddle.net/J8TLV/< /a>
As Scott says, there are different ways to do this. If you images have specific width and height, then see if my example fits you:
http://jsfiddle.net/J8TLV/
这只是基本的浮动:
我假设了如下所示的 HTML 结构:
演示:http://jsfiddle。净/Eg8un/11/
It's just basic floats:
I assumed a HTML structure like the one below:
Demo: http://jsfiddle.net/Eg8un/11/
既然他们做了浮动,我就做绝对定位。 缺点是更多的CSS。 优点是可以保持源顺序(图像 1-8 在 html 中如此排序)。我关闭了 Frexuz 的 jsfiddle http://jsfiddle.net/J8TLV/3/。
我想我会更新另一个(相关)优势,即图像可以放置在“行”和“列”网格中的任何位置,而无需重新排序图像本身(如你需要使用
float
)。Since they did the floats, I'll do the absolute positioning. The disadvantage is more css. The advantage is that source order can be maintained (images 1-8 are ordered so in the html). I toggled off Frexuz's jsfiddle http://jsfiddle.net/J8TLV/3/.
I thought I would update on another (related) advantage, that the images can be positioned anywhere in the "row" and "column" grid without reordering the images themselves (as you would need to with
float
).