如何在表格单元格上添加边框,而不是在html上添加整个表格?

时间:2016-10-11 01:42:14

标签: html css html-table

我正在尝试在表格单元格上添加边框,但我无法弄清楚如何使用rowspan。

我想要一个有4个单元格的表 左边有1个大单元,右边有3个小单元。

这是我使用的代码

的jsfiddle [点]净/ 1fv4dz5g / 3 /

2 个答案:

答案 0 :(得分:2)

这可以使用CSS完成。检查此css示例



td {
  border: 1px solid black;
}

<table class="tnews-side" border="0">

<tr>
<td rowspan="3">
<table border="1" cellpadding="4" cellspacing ="0">Row 1 Cell 1</table>
</td>
  <td>Row 1 Cell 2</td>
</tr>
<tr>
  <td>Row 2 Cell 2</td>
</tr>
<tr>
  <td>Row 2 Cell 2</td>
</tr>
</table>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

使用CSS有两种方法:

设置每个/所有import math import time primfac=[] def primcheck(n): for x in xrange(2, int(n**0.5)+1): if n % x == 0: return False return True def primes(n): sieve = [True] * n for i in xrange(3,int(n**0.5)+1,2): if sieve[i]: sieve[i*i::2*i]=[False]*((n-i*i-1)/(2*i)+1) return [2] + [i for i in xrange(3,n,2) if sieve[i]] def factfind(lsp,n): #finds factors of n among primes for i in lsp: if n%i==0: primfac.append(i) else: i+=1 def simplify(lsp, n): x = 1 for i in lsp: x=i*x if x != n: print "needs exponent, computing" for i in lsp: y=n/i if primcheck(y) == True: lsp.append(y) else: lsp.append(factfind(primes,y)) def primfacfind(n1,n2): global primfac while n1 <= n2: time_start = time.clock() if primcheck(n1) == True: print "prime" time_elapsed = time.clock() - time_start print "time:", time_elapsed n1+=1 else: n = n1 print "starting #", n factfind(primes(n),n) print primfac del primfac primfac = [] simplify(primfac, n) time_elapsed = time.clock() - time_start print "time:", time_elapsed n1+=1 primfacfind(6,15) 一个类并使用css border:

td

或者您可以使用嵌套选择或<style> .bigCell{border:1px solid black;} .smallCell{border-left:1px solid black;} </style> ... <td class="biCell"> ... <td class="smallCell"> 选择器

:nth-child()
你可以查看: https://css-tricks.com/almanac/selectors/n/nth-child/