gpt4 book ai didi

javascript - 如何选择 div 表的第一列?

转载 作者:太空宇宙 更新时间:2023-11-03 20:43:38 26 4
gpt4 key购买 nike

我正在尝试将我的 div 表中的第一列和第一行设为粗体。我设法把第一行加粗了。但是我不能让第一列看起来很粗。

下面你可以看到我的 html-css-javascript。如何使第一列看起来粗体

    <style type="text/css">
body {background: white; margin: 20px;}
h2 {margin: 20px 0;}
.zebraStyle > tbody > tr:nth-child(2n+1) > td {background: #e0e0d1;}
.firstRowStyle > tbody > tr:nth-child(1) > td {font-weight: Bold;}
.firstColumnStyle > tbody > tr:eq(1) {font-weight: Bold;}
</style>

<script type='text/javascript'>
var arr= [["", "2012", "2013", "2014(YTD)"],["Ferrari", 1460089088.3900001, 1637243070.99, 283566771.55000001],["Alfa Romeo", 1199141138.1900001, 1224624821.1500001, 192307335.49000001]];

$(document).ready( function(){
$('#myTable').handsontable({
data: arr,
minSpareRows: 1,
contextMenu: true,
readOnly: true,
fixedColumnsLeft: 1
});
$('#myTable').find('table').addClass('zebraStyle');
$('#myTable').find('table').addClass('firstRowStyle');
$('#myTable').find('table').addClass('firstColumnStyle');

});
</script>
</head>
<body>
<div id="myTable" class="handsontable" style="width: 400px; margin-left:auto; margin-right:auto; background-color:silver"></div>
</body>

最佳答案

使用下面的CSS

#myTable tr td:first-child{
font-weight:bold;
}

这将选择第一个 td

关于javascript - 如何选择 div 表的第一列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23675252/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com