【问题标题】:KDB & HTML/CSS: How to bold text of the first column of table?KDB & HTML/CSS:如何加粗表格第一列的文本?
【发布时间】:2019-01-08 08:24:33
【问题描述】:

我正在使用 KDB 自动生成 HTML 输出。如果可能的话,我想避免用类标记 html,因为我不想重新编写 KDB 代码。我尝试使用第一个孩子,但它没有用。还有其他建议吗?

KDB:

.util.html.t:{[t]
  if[not type[t] in 98 99h; :"Result not a table type!"];
  r:"<table cellSpacing='0' cellPadding='2'>";
  r:r,"<tr class='title'>";
  r:r,(,/){"<th>",x,"</th>"} each string cols t;
  r:r,"</tr>";
  r:r,(,/){"<tr>",((,/){
    if[type[x]=type[""]; x:`$x];
    if[not type[x]=type[enlist ""]; 
      x:string x;
      if[x like "*[0-9]%"; :"<td class=\"centeralignum\">",x,"</td>"];
      ];
    if[type[x]=type[enlist ""]; x:"," sv x];
    :"<td>",x,"</td>";
  } each x),"</tr>"} each 0!t;
  r:r,"</table>";
  :r;
  }

CSS:

     h3 { font-size: 16px; font-weight: bold; font-family: Calibri } 
     body { font-size: 12px; font-family: Calibri } 
     tr.title { background: lightblue repeat-x left bottom; font-weight: bold; border: 1px solid #000000;} 
     th {border: 1px solid black;}
     table { border: 1px solid black; border-collapse: collapse;}
     table td {border-left: 1px solid black; border-right: 1px solid black; width:125px;}
     table td:first-child {font-weight: bold;}
     td.centeralignum {text-align: center}

HTML

<table cellSpacing='0' cellPadding='2'><tr class='title'><th>name</th><th>a</th><th>b</th><th>c</th></tr><tr><td>bob</td><td>1</td><td>4</td><td>7</td></tr><tr><td>anna</td><td>2</td><td>5</td><td>8</td></tr><tr><td>ray</td><td>3</td><td>6</td><td>9</td></tr></table>

【问题讨论】:

    标签: html css formatting styles kdb


    【解决方案1】:

    在您提供的 Firefox 上使用 HTML 和 CSS 对我有用。我什至切换了第一个子属性以确保它是导致它的原因。 first-child 属性已经支持了很长一段时间,但值得检查here 以查看您的浏览器是否支持它。

    您可以进入浏览器上的开发人员工具并在检查器中选择元素以查看正在应用的样式。如果它们被覆盖,它们将有一个删除线,您还可以在开发者工具中切换属性或添加新属性,以查看它们如何更改显示

    【讨论】:

      猜你喜欢
      • 2023-03-03
      • 2018-07-29
      • 2013-01-19
      • 1970-01-01
      • 2023-03-31
      • 2013-08-11
      • 1970-01-01
      • 1970-01-01
      • 2015-05-22
      相关资源
      最近更新 更多