2010-10-04 13 views
1

我在这里做了一个整洁的小照相馆 - http://schnell.dreamhosters.com/wallpapers.php为什么我的一些表格单元比其他单元有更多的填充?

随意环顾四周,并采取了一些壁纸,如果你喜欢,这就是它的存在了。

不管怎么说,我遇到的问题是,如果你在列看起来非常接近,第一和最后的有从中间的那些不同量的填充。以下是相关的CSS此页......

html, body, div, span, applet, object, iframe, 
h1, h2, h3, h4, h5, h6, p, blockquote, pre, 
a, abbr, acronym, address, big, cite, code, 
del, dfn, em, font, img, ins, kbd, q, s, samp, 
small, strike, strong, sub, sup, tt, var, 
b, u, i, center, 
dl, dt, dd, ol, ul, li, 
fieldset, form, label, legend, 
table, caption, tbody, tfoot, thead, tr, th, td { 
    margin: 0; 
    padding: 0; 
    border: 0; 
    outline: 0; 
    font-size: 100%; 
    background: transparent; 
} 
a:visited { 
    color: blue; 
} 
body { 
    line-height: 1; 
} 
ol, ul { 
    list-style: none; 
} 
blockquote, q { 
    quotes: none; 
} 
blockquote:before, blockquote:after, 
q:before, q:after { 
    content: ''; 
    content: none; 
} 

/* remember to define focus styles! */ 
:focus { 
    outline: 0; 
} 

/* remember to highlight inserts somehow! */ 
ins { 
    text-decoration: none; 
} 
del { 
    text-decoration: line-through; 
} 

/* tables still need 'cellspacing="0"' in the markup */ 
table { 
    border: solid 1px black; 
    border-collapse: collapse; 
    border-spacing: 0; 
} 

td { 
    border: solid 1px black; 
    padding: 5px; 
    text-align: center; 
} 

#gallery { 
    margin: 10px auto; 
    width: 960px; 
} 

#fancybox-title { 
    font-size: 1.2em !important; 
    font-weight: bold !important; 
} 

.nav { 
    font-weight: bold; 
    font-size: 1.1em; 
    text-decoration: none; 
} 

.padding { 
    padding: 0 0.75em; 
} 

我不标记,并且添加填充是TD标签的唯一CSS样式添加任何填充,所以我很困惑,为什么中心列比外部列获得更多的填充。我试图带走填充类,也许与链接的细胞正在使细胞的增长,使图像单元格需要更多的填充,但没有奏效。

抱歉,如果这似乎有点微不足道,但我倾向于是相当OCD,当它的代码涉及到视觉效果,有时还完美主义者。

回答

3

这不是引起额外空白的表格单元填充。这就是表格的960像素宽度是如何在之间划分的这些列。尝试为每列指定相同的宽度,同时为边框计算几个像素。

+0

这样做。我将宽度更改为900px,现在额外的填充已消失。也很有趣,因为我一直都认为我超过了960px的标记,但我猜不是。 – 2010-10-04 18:52:24

1

快速查看你的html,我可以看到它不是填充是不同的。尝试将宽度放在所有列中,并从表格中移除宽度。

试试这个:

html, body, div, span, applet, object, iframe, 
h1, h2, h3, h4, h5, h6, p, blockquote, pre, 
a, abbr, acronym, address, big, cite, code, 
del, dfn, em, font, img, ins, kbd, q, s, samp, 
small, strike, strong, sub, sup, tt, var, 
b, u, i, center, 
dl, dt, dd, ol, ul, li, 
fieldset, form, label, legend, 
table, caption, tbody, tfoot, thead, tr, th, td { 
    margin: 0; 
    padding: 0; 
    border: 0; 
    outline: 0; 
    font-size: 100%; 
    background: transparent; 
} 
a:visited { 
    color: blue; 
} 
body { 
    line-height: 1; 
} 
ol, ul { 
    list-style: none; 
} 
blockquote, q { 
    quotes: none; 
} 
blockquote:before, blockquote:after, 
q:before, q:after { 
    content: ''; 
    content: none; 
} 

/* remember to define focus styles! */ 
:focus { 
    outline: 0; 
} 

/* remember to highlight inserts somehow! */ 
ins { 
    text-decoration: none; 
} 
del { 
    text-decoration: line-through; 
} 

/* tables still need 'cellspacing="0"' in the markup */ 
table { 
    border: solid 1px black; 
    border-collapse: collapse; 
    border-spacing: 0; 
} 

td { 
    border: solid 1px black; 
    padding: 5px; 
    text-align: center; 
    width:200px; 
} 

#gallery { 
    margin: 10px auto; 
} 

#fancybox-title { 
    font-size: 1.2em !important; 
    font-weight: bold !important; 
} 

.nav { 
    font-weight: bold; 
    font-size: 1.1em; 
    text-decoration: none; 
} 

.padding { 
    padding: 0 0.75em; 
} 
+0

假设这不会有colspans> 1,我想我会在将来这种方法去,但不是在外部样式表声明的话,我会用动态PHP这样生成它TDS螺丝td宽度加起来就像960这样的好数字。或者我也可以在飞行中生成整个表格的宽度。 – 2010-10-04 18:54:34

1

更改表格的宽度从960像素到一个较小的值...我想930px和所有补白看起来是一样的。

你必须计算:图像宽度= 176,5个图像使880,填充有50(总),边界是6 ...所有936一起设置表是936px宽。

+0

是的,我在后端使用PHP来计算动态缩略图的宽度。我想我错算了,忘了解释一些事情。 – 2010-10-04 18:53:09

4

960像素/ 5cells = 192px每个细胞

  • 每个图像是176px宽。
  • 每个单元格 具有10px的水平填充。
  • 每个单元都有一个像素边框(×2)
  • 188px每个细胞。

对于每个表格单元格(共20px),有4个下落不明。

因此,如果您将#gallery宽度减少到940px,则浏览器将不会有额外的宽度来决定如何处理。

+1

单元格边界崩溃。所有边框的总宽度是6px,而不是10px。表格宽度应该设置为936px。 – 2010-10-04 18:34:37

+0

谢谢,我想我已经错误地计算了某个地方,或者我预计在我的计算中基于960的所有东西都会导致960的净宽度,但由于我必须设置一些分数,所以我猜这不会发生。考虑到填充,边框和列数,我应该能够动态地计算出PHP需要的确切表格宽度。 – 2010-10-04 18:57:09

相关问题