id, 为什么没有效果???

L3nnon 2011-06-08 09:36:13

<html>
<head>
<title></title>
<style type="text/css">
table {border: 5px solid purple;}

#Table2 {border: green;} <----- id 设置
</style>

</head>
<body>
<table>
<tr>
<th>Header 1</th>
<th>Header 2</th>
<th>Header 3</th>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
<td>Data 3</td>
</tr>
</table>

<table id="Table2"> <----- id 设置
<tr>
<th>Header 1</th>
<th>Header 2</th>
<th>Header 3</th>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
<td>Data 3</td>
</tr>
</table>
</body>
</html>
...全文
133 17 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
heavenboya 2011-06-08
  • 打赏
  • 举报
回复
在id前面少了#
<table id="Table2"> <-----------应该是<table id="#Table2">
KK3K2005 2011-06-08
  • 打赏
  • 举报
回复
没怎么样 无效就说明你写错了
你吧table3 的 css 复制到table2 里面 看看有没有效

L3nnon 2011-06-08
  • 打赏
  • 举报
回复
[Quote=引用 14 楼 x_series 的回复:]

建议楼主把基础知识再好好看看
[/Quote]

正在 看着基础的书~ O_oll
x_series 2011-06-08
  • 打赏
  • 举报
回复
建议楼主把基础知识再好好看看
L3nnon 2011-06-08
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 inetfuture 的回复:]

我勒个去……洗洗睡……
[/Quote]

<html>
<head>
<title></title>
<style type="text/css">
#Table1 {border: 5px solid purple;}

#Table2 {
border-style: dotted;
border-width: 9px;
border-color: green;
}

#Table3 {
border-top: 3px double;
border-bottom: thick dashed;
border-right: thin inset red;
border-left: 5px solid blue;
}
</style>

</head>
<body>
<table id="Table1">
<tr>
<th>Header 1</th>
<th>Header 2</th>
<th>Header 3</th>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
<td>Data 3</td>
</tr>
</table>

<table id="Table2">
<tr>
<th>Header 1</th>
<th>Header 2</th>
<th>Header 3</th>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
<td>Data 3</td>
</tr>
</table>

<table id="Table3">
<tr>
<th>Header 1</th>
<th>Header 2</th>
<th>Header 3</th>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
<td>Data 3</td>
</tr>
</table>
</body>
</html>

Table1 有效
Table2 ((无效))
Table3 有效

怎么会这样的??
inetfuture 2011-06-08
  • 打赏
  • 举报
回复
我勒个去……洗洗睡……
L3nnon 2011-06-08
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 inetfuture 的回复:]

换个div什么的呢?
[/Quote]

什么是div??
inetfuture 2011-06-08
  • 打赏
  • 举报
回复
换个div什么的呢?
L3nnon 2011-06-08
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 t5500 的回复:]

没问题啊。你有多个测试文件吧,是不是点错了一个html文件。右键看下源代码。
[/Quote]
没点错~
Table1 有效果~ Table2 没效果~ O_oll
乌镇程序员 2011-06-08
  • 打赏
  • 举报
回复
没问题啊。你有多个测试文件吧,是不是点错了一个html文件。右键看下源代码。
L3nnon 2011-06-08
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 inetfuture 的回复:]

楼主浏览器有问题吧……换个浏览器试试
[/Quote]
试了~ 还是没反应 O_oll
火狐(Firefox) 和 IE8 都试了, 结果一样~
inetfuture 2011-06-08
  • 打赏
  • 举报
回复
楼主浏览器有问题吧……换个浏览器试试
L3nnon 2011-06-08
  • 打赏
  • 举报
回复

<html>
<head>
<title></title>
<style type="text/css">
#Table1 {border: 5px solid purple;}

#Table2 {border-style: dotted;
border-width: 9px;
border-color: green;
}
</style>

</head>
<body>
<table id="Table1">
<tr>
<th>Header 1</th>
<th>Header 2</th>
<th>Header 3</th>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
<td>Data 3</td>
</tr>
</table>

<table id="Table2">
<tr>
<th>Header 1</th>
<th>Header 2</th>
<th>Header 3</th>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
<td>Data 3</td>
</tr>
</table>
</body>
</html>


没有反应 O_oll
L3nnon 2011-06-08
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 inetfuture 的回复:]

HTML code

#Table2 { border: solid 1px green; }


border-style 不能为none border-width 不能为0 得先有border才能设置颜色吧……
[/Quote]
[Quote=引用 3 楼 t5500 的回复:]

实际上前面给table定义的样式对两个表格都有效,只是定义#Table2样式时用的是简写形式,相当于:
#Table2 { border: border-style默认值 border-width默认值 颜色; } ,boder-style的默认值是none,此时border-width值自动设为0.
[/Quote]
不明白~~~
不明白~~~ 求例子~~
乌镇程序员 2011-06-08
  • 打赏
  • 举报
回复
实际上前面给table定义的样式对两个表格都有效,只是定义#Table2样式时用的是简写形式,相当于:
#Table2 { border: border-style默认值 border-width默认值 颜色; } ,boder-style的默认值是none,此时border-width值自动设为0.
inetfuture 2011-06-08
  • 打赏
  • 举报
回复

#Table2 { border: solid 1px green; }

border-style 不能为none border-width 不能为0 得先有border才能设置颜色吧……
乌镇程序员 2011-06-08
  • 打赏
  • 举报
回复
#Table2 { border-color: green; }

61,129

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧