css - 如何水平对齐多个图像(连续)?

标签 css image alignment overflow

如何水平对齐多张图像,一张一张地?它们不必适合宽度屏幕:相反,我希望它们超过后者的宽度,如果这有任何意义的话。

我已经检查了很多类似问题的答案,但找不到任何可以解决我的问题的答案。

HTML:

<div id="content">
    <img src="Content/Images/Personal/Georges.jpg" alt="Georges" class="images" />
    <img src="Content/Images/Personal/Rose.jpg" alt="Gers" class="images" />
    <img src="Content/Images/Personal/Henry.jpg" alt="Providence" class="images" />
</div>

CSS:

.images
{
display: inline;
margin: 0px;
padding: 0px;
}

#content
{
display: block;
margin: 0px;
padding: 0px;
position: relative;
top: 90px;
height: auto;
max-width: auto;
overflow-y: hidden;
overflow-x:auto;
}

提前谢谢你。

最佳答案

实际上,您希望防止 inline img 元素包装,因此,您希望在父 #content 上使用以下内容> 元素:

white-space:nowrap;

Demo Fiddle

More on white-space from MDN

nowrap Collapses whitespace as for normal, but suppresses line breaks (wrapping).

此样式专门用于您需要的目的。

关于css - 如何水平对齐多个图像(连续)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25202348/

相关文章:

jquery - 带有渐变和边框的文本

javascript - jquery淡出/淡入闪烁问题

c# - 无法访问 HTML 中定义的图像控件,在 C# 文件后面的代码中

WPF:对齐标签的基线及其文本框

html - 无法使用 CSS 在 HTML 页面上移动文本

html - 在 html 中使用 css 的 boxsize

jquery - 如何将 jqgrid 列与列标题对齐?

image - 如何提高图像的强度对比度?

ios - 通过Parse框架AFNetworking2.0使用RESTAPI上传图片报错

html - CSS 百分比对齐问题