这是四个图像(宽度 = 160px)的流畅设计,带有 ul 或浮动 div。调整窗口大小时一切都很好。它是流动的。
但是当我传递到一个绝对位置时,我最初发现不再有 160px。
你可以在这里看到问题http://jsfiddle.net/zXDH9/
代码:
<html>
<head>
<style>
body { position:relative; }
.container {
/* remove comment to view problem */
/*position:absolute; left:0; top:0;*/
margin: 0;
padding: 0;
border: black 1px solid;
max-width: 690px;
overflow: hidden;
}
.galleryItem {
float: left;
width: 23%;
margin: 0 1%;
padding: 1% 0;
}
.galleryItem img { max-width: 100%; }
ul { list-style: none; }
ul.thumbs {
/* remove comment to view problem */
/*position: absolute; left:0; top: 100px;*/
display: block;
margin: 0;
padding: 0;
border: black 1px solid;
max-width:690px; overflow: hidden;
}
ul.thumbs>li {
display: block;
float: left;
width: 23%;
margin: 0 1%;
padding: 1% 0;
}
ul.thumbs>li img {
display: block;
max-width: 100%;
}
</style>
</head>
<body>
<div class="container">
<div class="galleryItem"><a href="#"><img src="http://www.e-business.tn/focus/images/galleria/hobs/thumbs/F.801X_mini.jpg" alt="" /></a></div>
<div class="galleryItem"><a href="#"><img src="http://www.e-business.tn/focus/images/galleria/hobs/thumbs/F.802X_mini.jpg" alt="" /></a></div>
<div class="galleryItem"><a href="#"><img src="http://www.e-business.tn/focus/images/galleria/hobs/thumbs/F.801W_mini.jpg" alt="" /></a></div>
</div>
<ul class="thumbs">
<li class=""><a href="#"><img src="http://www.e-business.tn/focus/images/galleria/hobs/thumbs/F.801X_mini.jpg" alt="" /></a></li>
<li class=""><a href="#"><img src="http://www.e-business.tn/focus/images/galleria/hobs/thumbs/F.802X_mini.jpg" alt="" /></a></li>
<li class=""><a href="#"><img src="http://www.e-business.tn/focus/images/galleria/hobs/thumbs/F.801W_mini.jpg" alt="" /></a></li>
</ul>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js">/*jQuery 1.5.1 Supports IE9, but not 1.5.0*/</script>
<script>
$(function(){ // Document is ready
/*alert($('ul.thumbs').outerWidth(true));*/
});
</script>
</body>
</html>