使用 CSS 在网页中心对齐照片(带标题)
我试图在我的网页上创建一个照片块(它有一个设定的宽度,我没有复制那部分代码)。我已将代码放入下面的 JSFiddle 链接中。
我将重新创建我想要做的事情图形编辑器。单击此处查看:http://www.flickr.com/photos/adpartners /6630840127/in/photostream
我不确定我的 css/html 做错了什么。一切都卡在左侧,因为我在我的 div 标签之一中使用了 float left。我真的希望背景居中,确实如此,然后将图像放在其顶部,如下所示:3 张照片,2 张照片,1 张照片,2 张照片。它们都会链接到 YouTube 视频,我已经获得了该部分的链接。
任何帮助将不胜感激。我已经用
完成了该代码的 10-20 个不同版本 p、div、table、ol/li 标签,老实说,现在不知道该使用哪一个。
如果您发现我做错了什么,请填写我的信息。我失去了代码!
非常感谢您提供的任何帮助, 右
I am trying to create a block of photos on my webpage (Which has a set width, I didn't copy that part of the code over). I have put the code into the JSFiddle link below.
I will recreate what I am trying to do on a graphic editor. Click here to view it: http://www.flickr.com/photos/adpartners/6630840127/in/photostream
I'm not sure what I am doing wrong with my css/html. Everything is stuck on the left because I used float left in one of my div tags. I really want the background to be centered, which it is, then have the images over the top of it, like so: 3 photos, 2 photos, 1 photo, 2 photos. They will all link to youtube videos, which I have already got the links already for that part of it.
Any help would be much appreciated. I have done 10-20 different versions of this code with
p, div, table, ol/li tags, and honestly don't know which one to use for this now.
If you see what I am doing wrong, please fill me in. I'm at a loss of code!
Many thanks for any help you might offer,
R
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
display: inline-block
和text-align: center
代替。只要
.containerVid
足够宽,图像就会继续堆叠,直到不再适合该行。如果您想强制提前休息,只需添加
(就像您一直在做的那样)。小提琴:http://jsfiddle.net/T2qHR/20/
Use
display: inline-block
andtext-align: center
instead.As long as
.containerVid
is wide enough, images will continue to stack up until they no longer fit in the row. If you want to force a break early, simply add a<br />
(as you've been doing).fiddle: http://jsfiddle.net/T2qHR/20/