【发布时间】:2013-07-07 04:18:03
【问题描述】:
我正在尝试在 2 个 div 中实现过去和未来的图片线。屏幕左侧的所有图片从右到左堆叠到无穷大,屏幕右侧的所有图像从左到右堆叠到无穷大。我几乎已经实现了这一点,只是我无法阻止图像换行。
HTML
<div id="parent1">
<div id="past">
<img id="topic1" src="./img/topic1.png"></img>
<img id="topic2" src="./img/topic2.png"></img>
...
</div>
<div id="future">
<img id="topic1a" src="./img/topic1a.png"></img>
<img id="topic2b" src="./img/topic2b.png"></img>
...
</div>
</div>
CSS
#parent {
position: absolute;
height: 100%;
width: 100%;
top: 0%;
left: 0%
}
#future {
position: absolute;
height: 100%;
width:50%;
left:50%;
top:0%
}
#future img {
float: left;
height: auto;
width: auto;
margin: 1%;
max-height: 100%;
white-space: nowrap;
}
#past {
position: absolute;
height: 100%;
width:50%;
left:0%;
top:0%
}
#past img {
float: right;
height: auto;
width: auto;
margin: 1%;
max-height: 100%;
white-space: nowrap;
}
任何帮助都会很棒。目前它们垂直堆叠到无穷大:(
【问题讨论】:
-
除非我使用了 nowrap。还是没有解决问题
-
你能添加一个JSFiddle 来展示你的代码吗?当图像显示为内联块时,您可能会摆脱浮动,所以我认为不需要它们
-
jsfiddle.net/XHacq 第一次小提琴,很有趣
-
摆脱浮动确实将它们并排放置,但我希望左侧堆栈在左侧,右侧堆栈在右侧
-
我在你的 jfiddle 中学到的东西比我从我读过的所有网站中学到的更多:p 现在需要重新编写我所有的 css
标签: css image css-float whitespace nowrap