见上文:) See above :) Giggle Girl写道:Giggle Girl wrote:你好! :) 我正在开发一个使用数十个表的应用程序,其中一些表有数百行(甚至数千行)。我有兴趣使用尽可能多的CSS来格式化表格,因此HTML是准系统并且易于阅读/修改。在想到如何做到这一点时,我提出了这个想法,我欢迎评论: 问题:使用一个字母的类名有什么优缺点对于常见的TD单元格格式,例如nowrap或align = right等。 这样的事情: 。{text-align:left; } .c {text-align:center; } 。{text-align:right; } .t {vertical-align:top; } .m {vertical-align:middle; } .b {vertical-align:bottom; } .w {white-space:wrap; } .nw {white-space:nowrap;这将使你能够做速记。用于格式化单元格,例如这个: < td class =" ct nw"> 1亿< / td> 这个特定的单元格居中水平,垂直中间,没有包装...... 您怎么看? 使用样式的关键是将内容与演示文稿分开。一个 的优点是你可以通过改变样式表而不必触摸HTML来完全改变外观 特别是无需通过它进行搜索并对要更改其外观的每个元素进行更改。 如果您将类放在HTML中引用直接到外观,然后 假设您认为您希望所有以前对齐的单元格 为中心对齐。你必须浏览你的HTML并更改所有类别的b $ b。您*可以*只需更改CSS中的一行即可阅读 .r {text-align:center; } 如果你的意思是改变是普遍的。但那会很傻, 不是吗? 除非你的格式格式完全随意,否则更改是 您出于某种原因正在应用这些样式。也许你想要 数字单元格是右上对齐的,你希望列标题是 底部中心对齐。那么有意义的是用class =" numeric"指定 单元格。和class =" colhead"然后有 .numeric {text-align:right; vertical-align:top; } .colhead {text-align:center; vertical-align:bottom; } b / b 我最担心的是处理器会变得昂贵。 Hello! :) I am working on an app that uses dozens of tables, some with hundreds (or even thousands!) of rows. I am interested in formatting the tables using as much CSS as possible, so the HTML is barebones and easy-to-read/modify. While thinking up how to do it, I came up with this idea, which I welcome comments on: QUESTION: What are the pros and cons of using one letter class names for common TD cell formatting, like "nowrap" or "align=right", etc. Something like this: .l { text-align : left; } .c { text-align : center; } .r { text-align : right; } .t { vertical-align : top; } .m { vertical-align : middle; } .b { vertical-align : bottom; } .w { white-space : wrap; } .nw { white-space : nowrap; } This would enable you to do "shorthand" for formatting cells, like this: <td class="c t nw">100 million</td> where this particular cell centered horizontally, middled vertically, and with no wrapping... What do you think?The point of using styles is to separate content from presentation. Oneof the advantages of that is that you can change the appearance entirelyby altering the stylesheet without having to touch the HTML, and inparticular without having to hunt through it and make changes to everyelement whose appearance you want to alter. If you put classes in your HTML that refer directly to appearance, thensuppose you decide you want all the cells that used to be right-alignedto be center-aligned. You have to go through your HTML and change allthe classes. You *could* just change one line in your CSS to read .r { text-align : center; } if you meant for the change to be universal. But that would be silly,wouldn''t it? Unless your cell formatting is completely haphazard, the changes arethat you are applying these styles for a reason. Perhaps you wantnumeric cells to be top-right-aligned, and you want column headers to bebottom-center-aligned. So what would make sense would be to designatecells with class="numeric" and class="colhead" and then have .numeric { text-align: right; vertical-align: top; }.colhead { text-align: center; vertical-align: bottom; } My biggest fear is it will get expensive processor-wise. 不是特别。 Not particularly. 2006年4月27日13:17:24 -0700,Giggle Girl < mi ******* @ gmail.com> 写道: :我最大的担心是它将获得昂贵的处理器。 你每毫秒玩多少? Sid On 27 Apr 2006 13:17:24 -0700, "Giggle Girl" <mi*******@gmail.com>wrote: : My biggest fear is it will get expensive processor-wise. How much do you play for each millisecond? Sid 这篇关于TD CSS Shorthands ......想法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-28 15:28