[英]Display images side by side 100% screen
我有一个HTML格式的div,这个div的宽度为100%。 在这个div我有很多照片,我想并排显示它们。
例:
Resolution of: 1000px (display 5 images side by side (200px width)) from 6 create a new row
并且图片填满了屏幕上的空白区域,因此用户只能看到图像而不能看到白色背景。
谢谢。
漂浮图像,使宽度为20%..
<div class="container">
<img src="1.jpg"/>
<img src="2.jpg"/>
<img src="3.jpg"/>
<img src="4.jpg"/>
<img src="5.jpg"/>
<img src="6.jpg"/>
</div>
和css
.container{overflow:hidden;}
.container img{
width:20%;
float:left;
}
http://jsfiddle.net/R5sq4/上的演示
更新由于评论提到在大屏幕上图像太大..
因此,您可能希望为图像设置最小/最大宽度,并强制它们填充页面,同时遵守这些限制。
你需要一些脚本。
$(function(){
var min = 200,
max = 300,
container = $('.container'),
images = container.children('img');
$(window).resize(function(){
var w = container.width(),
minfit = 100 / Math.floor(w / min),
maxfit = 100 / Math.floor(w / max);
images.css({width:Math.min(minfit,maxfit)+'%'});
}).resize();
});
用这个css
.container{overflow:hidden;}
.container img{
float:left;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.