CSS 浮动居中
谁能弄清楚为什么这些图像不会漂浮在中心吗?我已经浮动了剩下的所有内容,这样就不会被清除,但是 margin:auto 和 text-align:center;似乎没有效果。
我希望图像组两侧的边距与此屏幕截图 db.tt/aNu8zBVl 中所示的相同。
非常感谢 - 这是 JSfiddle - http://jsfiddle.net/SparrwHawk/UWYv3/3/
编辑
我希望图像组两侧的边距相同:
Can anyone figure out why these images won't float in the centre? I've floated everything left so that things aren't cleared, but margin:auto and text-align:centre; seem to be having no effect.
I would like the margins on both sides of the group of images to be the same as shown in this screenshot db.tt/aNu8zBVl
Many thanks - here's the JSfiddle - http://jsfiddle.net/SparrwHawk/UWYv3/3/
EDIT
I would like the margins on both sides of the group of images to be the same:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您在 jsfiddle.net 上发布的代码将平铺图像。从这方面来说,它运作良好。
您能提供一张图片来说明您尝试要实现的目标吗?
您有一个拼写错误,正如 Marc B 指出的那样:
text-align: center
(不是中心)。但是,
text-align:center
不会对产生任何影响,因为它们是浮动的。
这里有 2 个示例说明这个原理:
clear: left
所以只会有每一张图像 (也许这就是您想要实现的目标?)我留下了text-align:center
来证明它对浮动元素没有影响。text-align:center 正在做它的工作。
The code that you posted at jsfiddle.net will tile the images. In that regard, it's working fine.
Can you provide a picture of what you are trying to achieve?
You have a typo, as Marc B pointed out:
text-align: center
(not centre).However,
text-align:center
won't have any affect on the<img>
because they are floated.Here are 2 examples to illustrate this principle:
clear: left
so there will only be one image per line. (Perhaps this is what you are trying to achieve?) I lefttext-align:center
to demonstrate that it has no effect on floated elements.text-align:center
is doing it's job.