【发布时间】:2011-09-26 03:33:39
【问题描述】:
我正在尝试为表格中的所有表格单元格添加一个简单的边框。
重要的是,我的标记要保持简单,以便我可以使用其他一些功能。
假设我的 tds 样式如下:
$('td').css('border', '1px solid #000');
这是我的结果:
<td style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); border-left-color: rgb(0, 0, 0); ">…/td>
课程也不适合我正在尝试做的事情。为什么我的单元格以这种荒谬的方式格式化?
【问题讨论】:
-
为什么不适合上课?
-
这为 CSS 类尖叫?为什么不合适?如果您需要能够即时切换它们,那么我有一个简单的 CSS 解决方案,更干净
-
类不合适,因为用户可以编辑样式
-
@ionfish 当您说“这是专门在 chrome 中发生的”时,您的意思是它不会在其他浏览器中这样做吗?如果这是真的,您应该将其添加到问题中,并指定它在其他浏览器中 的作用 做什么。我猜想它在所有浏览器中都是一样的,因为我看不出有什么不同的原因。
-
不管 use-case 听起来是否是类的好案例,问题根本不在于这个。这就是为什么 jQuery 会做一些看起来很愚蠢的事情。
标签: jquery css html-table styling