为什么 布局会乱?

miao159 2009-07-19 03:29:10
div做得几列图片为什么总有一列空着????代码如下:
<div id="content" style="border:5px solid white;">
<div class="section clearfix">
<div class="thumbnail">
<a href="images/image-1.jpg" rel="lightbox[plants]" title="产品简介:"><img src="images/thumb-1.jpg" width="100px" height="100px" alt="Plants: image 1 0f 10 thumb" /></a>
</div>
<div class="thumbnail">
<a href="images/image-2.jpg" rel="lightbox[plants]" title="产品简介:" ><img src="images/thumb-2.jpg" width="100px" height="100px" alt="Plants: image 2 0f 10 thumb" /></a>
</div>
<div class="thumbnail">
<a href="images/image-3.jpg" rel="lightbox[plants]" title="产品简介:"><img src="images/thumb-3.jpg" width="100px" height="100px" alt="Plants: image 3 0f 15 thumb" /></a>
</div>
<div class="thumbnail">
<a href="images/image-4.jpg" rel="lightbox[plants]" title="产品简介:"><img src="images/thumb-4.jpg" width="100px" height="100px" alt="Plants: image 4 0f 15 thumb" /></a>
</div>
<div class="thumbnail">
<a href="images/image-5.jpg" rel="lightbox[plants]" title="产品简介:"><img src="images/thumb-5.jpg" width="100px" height="100px" alt="Plants: image 5 0f 15 thumb" /></a>
</div>
<div class="thumbnail">
<a href="images/image-6.jpg" rel="lightbox[plants]" title="产品简介:"><img src="images/thumb-6.jpg" width="100px" height="100px" alt="Plants: image 6 0f 15 thumb" /></a>
</div>
<div class="thumbnail">
<a href="images/image-7.jpg" rel="lightbox[plants]" title="产品简介:"><img src="images/thumb-7.jpg" width="100px" height="100px" alt="Plants: image 7 0f 15 thumb" /></a>
</div>
<div class="thumbnail">
<a href="images/image-8.jpg" rel="lightbox[plants]" title="产品简介:"><img src="images/thumb-8.jpg" width="100px" height="100px" alt="Plants: image 8 0f 15 thumb" /></a>
</div>
<div class="thumbnail">
<a href="images/image-9.jpg" rel="lightbox[plants]" title="产品简介:"><img src="images/thumb-9.jpg" width="100px" height="100px" alt="Plants: image 9 0f 15 thumb" /></a>
</div>
<div class="thumbnail">
<a href="images/image-10.jpg" rel="lightbox[plants]" title="产品简介:"><img src="images/thumb-10.jpg" width="100px" height="100px" alt="Plants: image 10 0f 15 thumb" /></a>
</div>
<div class="thumbnail">
<a href="images/image-11.jpg" rel="lightbox[plants]" title="产品简介:"><img src="images/thumb-11.jpg" width="100px" height="100px" alt="Plants: image 11 0f 15 thumb" /></a>
</div>
<div class="thumbnail">
<a href="images/image-12.jpg" rel="lightbox[plants]" title="产品简介:"><img src="images/thumb-12.jpg" width="100px" height="100px" alt="Plants: image 12 0f 15 thumb" /></a>
</div>
<div class="thumbnail">
<a href="images/image-13.jpg" rel="lightbox[plants]" title="产品简介:"><img src="images/thumb-13.jpg" width="100px" height="100px" alt="Plants: image 13 0f 15 thumb" /></a>
</div>
<div class="thumbnail">
<a href="images/image-14.jpg" rel="lightbox[plants]" title="产品简介:"><img src="images/thumb-14.jpg" width="100px" height="100px" alt="Plants: image 14 0f 15 thumb" /></a>
</div>
<div class="thumbnail">
<a href="images/image-15.jpg" rel="lightbox[plants]" title="产品简介:"><img src="images/thumb-15.jpg" width="100px" height="100px" alt="Plants: image 15 0f 15 thumb" /></a>
</div>
</div>
<!-- end .section -->
<div class="section"></div>
<!-- end .section --><!-- end .section -->
</div>
<!-- end .content -->
...全文
76 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
miao159 2009-07-19
  • 打赏
  • 举报
回复
非常感谢
bwangel 2009-07-19
  • 打赏
  • 举报
回复
你采用的流式布局,如果容器整宽度不是图片+边距的尺寸的整数倍的话,最后一列刚好宽度差一点,当然就只能空着啦. 所以要把宽度一个px一个px都计算好.
再不行,就用表格布局,肯定不会有空一列的请况啦.
miao159 2009-07-19
  • 打赏
  • 举报
回复
//////////////////第一个css文件
screen.css
*{
margin: 0;
padding:0;
}
body{
background: #1A1A1A;
color: #eee;
font: 76% 'Lucida Grande', 'Lucida Sans Unicode', Verdana, sans-serif,;
word-wrap: break-word; /* IE */
}

#topborder{
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 1.0em;
background-color: #c0dB5A;
}

#sidebar{ position:fixed; top: 38px; left:20px; width: 250px; }
* html div#sidebar { top: 38px; left:20px; width: 250px; position:absolute; }

/*#content{ margin: 50px 10% 5em 50px; }*/
#content{ margin:0;padding:0;}


/* typography
----------------------------------------------- */

p { line-height: 1.5em; margin-bottom: 1.0em; font-size: 0.9em;}
p.lead { font-size: 1.0em; }

ol, ul{ margin: 0.5em 0 1.2em 2em; }
ol, ul, dl { line-height: 1.5em; }
ol li{ margin-bottom: 0.2em; }
li{ font-size: 0.9em; }
li strong {color: #999;}
dl{ margin: 0.5em 0 1.2em 0; }
dt{
font-size: 0.9em;
font-weight: bold; color: #999;
padding-top: 0.4em;
}
dd{
font-size: 0.9em;
margin-bottom: 1.0em;
padding-bottom: 0.9em;
border-bottom: 1px dashed #3d3d33;
}


h1, h2, h3{ font-family: "Trebuchet MS",Verdana,Sans-Serif;}

h1 { font-size: 2.5em; }
h1 a { color:#fff; border: none; }
h1 em{ color: #D0EB6A; font-style: normal; }

h2 {
font-size: 1.5em;
letter-spacing: 0.4pt;
color: #D0EB6A;
text-transform: uppercase;
padding-top: 0.5em;
}
h3 {
font-size: 1.0em;
letter-spacing: 0.2pt;
color: #c0dB5A;
text-transform: uppercase;
padding-top: 0.5em;
}

a{
font-weight: bold;
color: #8ad459;
text-decoration: none;
}

p a:hover { border-bottom: 1px dotted #8ad459; }
a img{ border: none;}

small{ font-size: 0.8em; }

pre{
display: block;
margin: 1.0em 0;
padding-left: 0.8em;
border-left: 1px solid #222;
background-color: #000;
overflow: auto;
}

code{
font-size: 11px;
font-family: Verdana,Sans-Serif;
background-color: #000;
color: #aaa;
}
pre code{ line-height: 1.1em;}
kbd{
color: #555;
background-color: #ddd;
border-right: 1px solid #ccc;
border-bottom: 1px solid #ccc;
font-size: inherit;
font-family: inherit;
padding: 0 3px 2px 4px;
}

fieldset{ border: none; }

/* sidebar
----------------------------------------------- */
#sidebar a{
color: #fff;
}
#sidebar p a:hover{ border-bottom: 1px dotted #fff; }

#sidebar h1 a{ font-weight: bold; }
#sidebar h1 a:hover{ color: inherit; }

#nav{ list-style: none; margin: 2.0em 0; width: 15em;}
#nav li{ padding: 0; margin: 0; }
#nav a{
display: block;
height: 2.0em;
padding: 0.3em 0.2em 0.2em 0.8em;
border-bottom: 1px solid #1a1a1a;
color: #eee;
background-color: #333;
}

#nav a:hover{
color: #1a1a1a;
background-color: #D0EB6A;
}


/* content
----------------------------------------------- */
/*#content ul{ margin-left: 4px;}
#content ul li{
list-style: none;
padding: 0 0 0 12px;
background: url(../images/bullet.gif) no-repeat 0 6px;
}
.download{
background-color: #333;
border: 1px solid #444;
padding: 0.7em 1.5em; }
.download:hover{
background-color: #555;
border: 1px solid #777;
}
#content ul.download li{
padding: 0.3em 0;
background-image:none;
}
.download img{ padding-right: 0.3em; }
.download li strong{ font-family: "Trebuchet MS",Verdana,Sans-Serif; font-size: 2.25em; color: #fff;}
.download li em{ font-style: normal; color: #D0EB6A; }*/

/* misc
----------------------------------------------- */

.section{ border-top: 1px solid #3d3d33; padding: 0;margin:0; }
.first{ border-top: none; }

.thumbnail{
padding: 5px;
background-color: #222;
border: 1px solid #2a2a2a;
float: left;
margin-right:10px;
margin-bottom: 10px;
}

.caption{ font-size: 0.9em; padding-top: 0.2em;}

/* clearing
----------------------------------------------- */

.clearfix:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}

* html>body .clearfix {
display: inline-block;
width: 100%;height:443px;
}

* html .clearfix {
/* Hides from IE-mac \*/
height: 1%;
/* End hide from IE-mac */
}

////////////////////第二个css文件
lightbox.css
#lightbox{
position: absolute;
left: 0;
width: 100%;
z-index: 100;
text-align: center;
line-height: 0;
}

#lightbox a img{ border: none; }

#outerImageContainer{
position: relative;
background-color: #fff;
width: 250px;
height: 250px;
margin: 0 auto;
}

#imageContainer{
padding: 10px;
}

#loading{
position: absolute;
top: 40%;
left: 0%;
height: 25%;
width: 100%;
text-align: center;
line-height: 0;
}
#hoverNav{
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
z-index: 10;
}
#imageContainer>#hoverNav{ left: 0;}
#hoverNav a{ outline: none;}

#prevLink, #nextLink{
width: 49%;
height: 100%;
background: transparent url(../images/blank.gif) no-repeat; /* Trick IE into showing hover */
display: block;
}
#prevLink { left: 0; float: left;}
#nextLink { right: 0; float: right;}
#prevLink:hover, #prevLink:visited:hover { background: url(../images/prevlabel.gif) left 15% no-repeat; }
#nextLink:hover, #nextLink:visited:hover { background: url(../images/nextlabel.gif) right 15% no-repeat; }


#imageDataContainer{
font: 10px Verdana, Helvetica, sans-serif;
background-color: #fff;
margin: 0 auto;
line-height: 1.4em;
overflow: auto;
width: 100%
}

#imageData{ padding:0 10px; color: #666; }
#imageData #imageDetails{ width: 70%; float: left; text-align: left; }
#imageData #caption{ font-weight: bold; }
#imageData #numberDisplay{ display: block; clear: left; padding-bottom: 1.0em; }
#imageData #bottomNavClose{ width: 66px; float: right; padding-bottom: 0.7em; }

#overlay{
position: absolute;
top: 0;
left: 0;
z-index: 90;
width: 100%;
height: 500px;
background-color: #000;
}

62,047

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧