javascript - 使用 ngStyle 将样式分配给 tr :first-child td

标签 javascript html css angularjs html-table

我动态获取我的数据,所以它总是不同的。 我使用 .replacengStyle 添加到表中,但我如何为第一个 child (称为 td)提供样式?

我做了一个plunker所以你可以尝试一些东西。

最佳答案

你可以使用 ng-style 有条件地添加一个类,就像这样

<td ng-class="{'firstchild': 'someConditionGoesHere'}">Ali</td>

但是要为第一个 td 添加样式,您必须坚持使用基本的 css,例如

.tableStyle td:first-child 

您还可以做的是使用 ng-style 添加一个类 say 'test' 并具有类似

的 css 定义
.tableStyle td.firstchild:first-child {}

将这些组合在一起会为您解决。

关于javascript - 使用 ngStyle 将样式分配给 tr :first-child td,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34155903/

相关文章:

javascript - TypeScript 中 dom 元素的别名?

javascript - 为什么 'this' 与此 Backbone View 的绑定(bind)不一致?

javascript - 不使用库从 csv 文件中的文本数据创建 javascript 对象的步骤

html - 侧边栏低于内容和页脚不是 100%

javascript - Flexslider 无法使用 Jquery 自动生成内容

html - 简单的 HTML 渲染问题

javascript - 从json动态构建dom树

javascript - Accordion 的事件标题属性无法正常工作

html - 如何创建内联 h1 和跨度,并将跨度对齐到结尾?

javascript - 如何将 jquery unbind 设置为切换