【发布时间】:2012-11-08 03:28:37
【问题描述】:
如何根据浏览器的大小自动调整 img 组的大小?
我在css中几乎完成了,但现在我无法设置溢出:隐藏让第5个或第6个..图片隐藏。
(来自 php 的图像)
(我会连接jQuery插件scrolling-carousel。)
任何建议我都非常感谢你抽出时间。
这是我的http://jsfiddle.net/uSHbc/1/
HTML
<div class="conimgwrap2">
<div class="conimgwrap">
<div class="conimg">
<div>
<img src="http://fancyapps.com/fancybox/demo/2_s.jpg">
</div>
<div>
<img src="http://fancyapps.com/fancybox/demo/2_s.jpg">
</div>
<div>
<img src="http://fancyapps.com/fancybox/demo/2_s.jpg">
</div>
<div>
<img src="http://fancyapps.com/fancybox/demo/2_s.jpg">
</div>
<div>
<img src="http://fancyapps.com/fancybox/demo/2_s.jpg">
</div>
</div>
</div>
</div>
CSS
.conimgwrap2{
position: relative;
left: 50%;
width: 50%;
}
.conimgwrap{
position: absolute;
width: 25%;
height: 25%;
}
.conimg{
max-width: 100%;
max-height: 100%;
background-color: yellow;
display: inline;
white-space: nowrap;
}
.conimg div{
display: inline;
white-space: nowrap;
}
.conimg img{
max-width: 100%;
max-height: 100%;
}
【问题讨论】:
-
你已经完成了。通过将 max-height & max-width 设置为 100%,图像将根据浏览器大小调整大小。
-
但是我找不到隐藏img溢出img组容器的方法。
-
如果你想隐藏那个img组的溢出,把overflow:hidden;在 .conimg img{} 内
-
您究竟是想隐藏那张图片还是将溢出设置为隐藏? overflow 属性指定如果内容溢出元素的框会发生什么。