【发布时间】:2013-12-16 04:45:22
【问题描述】:
我有这个 CSS 代码:
#portrait{
height: 300px;
width: 550px;
border: solid;
margin-right: auto;
margin-left: auto;
word-wrap:break-word;
overflow:hidden;
}
.image{
float:left;
height: 30%;
border:solid 1px;
padding: 1px;
posit ion:relative;
}
和html:
<div id="portrait">
<img class="image" src="http://media.indiatimes.in/media/photogallery/2012/Dec/best_images_of_2012_1355117665_1355117684.jpg"/>
<!--Can't pull all images in here because it thinks my question is spam-->
<img class="image" src="http://adrao.com.sapo.pt/soajo_sol.jpg"/>
<img class="image" src="http://www.befrielsen1945.dk/temaer/internationalt/krigensgang/kilder/ofre.jpg"/>
<img class="image" src="http://ionenewsone.files.wordpress.com/2009/08/oj-simpson-smiling-murder-trial.jpg"/>
<img class="image" src="http://images.nymag.com/images/2/daily/2009/10/20091006_gossipgirl_560x375.jpg"/>
<img class="image" src="http://images.nymag.com/images/2/daily/2009/10/20091006_gossipgirl_560x375.jpg"/>
</div>
我想要做的是隐藏 x 轴中的图像溢出(而不是第一个金发女郎在第二行,我希望她在必要时被裁剪但仍保留在第一行等等)。当我做overflow-x hidden时它不会工作。对这个有什么想法吗?
【问题讨论】:
-
看看This Question它可能对你有帮助,你需要让你的图像在一个包含的div中彼此相邻浮动 - 这是小提琴示例http://jsfiddle.net/2s95M
-
Musa,除了“float:left”还有其他方法吗? Ty 为你回答 Wezly,但这正是我正在寻找的 Musa 所写的内容。
标签: css image google-chrome html