如何用css去除表格内、外边距和边框

html-css016

如何用css去除表格内、外边距和边框,第1张

需要准备的材料分别有:电脑、浏览器、html编辑器。

1、首先,打开html编辑器,新建html文件,例如:index.html,编写问题基础代码。

2、在index.html中的<style>标签中,输入css代码:td {padding: 0}。

3、浏览器运行index.html页面,此时成功用css去除了表格的边框和边距。

用ID吧

#table01{width:88%}

#table02{width:100%}

<table id="table01">//这是第一个表格

<table id="table02">//这是第二个表格

想应用更多不同样式的表格就另外在CSS设置 注意ID属性是唯一的

<html>

<head><title>HTML

Table</title></head>

<style

type="text/css">

TABLE

{

border-collapse:

separate

border:

2px

solid

blue

}

.one{

border-left:none

border-right:1px

solid

#f00

border-top:1px

solid

#f00

border-bottom:1px

solid

#f00}

</style>

<body>

<table

summary="TechRepublic.com

-

Tables

and

CSS">

<thead><tr>

<thabbr="salesperson"

scope="col">Person</th>

<thabbr="sales"

scope="col">Sales</th>

</tr></thead>

<tbody><tr>

<td

class="one">Mr.

Smith</td>

<td>600.00</td>

</tr><tr>

<td>Mr.

Jones</td>

<td>0000.00</td>

</tr><tr>

<td>Ms.

Williams</td>

<td

class="one">0000.00</td>

</tr></tbody>

<tfoot><tr>

<td>Let's

sale,

sale,

sale!</td>

</tr></tfoot></table></body></html>

我设置了一个样式one,单元格左边没有边框,上下和右边有边框,颜色你可以自己设置。