当前位置:编程学习 > html/css >>

懂HTMLcss语言的高手请进,菜鸟有如下问题不知! 请看下面完整的代码,为什么表格第一行的高度不一样呢?

<html> <head> <title>欧洲信息技术市场产值</title> <style type="text/css"> <!-- h1{font-family:黑体;font-size:30px;font-weight:bolder;text-align:center} #w1 {font-family:幼圆;font-size:15px;font-weight:bolder;text-align:center} #w2{font-family:黑体;font-size:15px;font-weight:bold} --> </style> </head> <body> <center> <h1>欧洲信息技术市场产值</h1> <table border=2 > <tr> <th colspan=2 height=50 width=150 id=w1>类别</th> <td height=30 width=100 id=w2>1999</td> <td height=30 width=100 id=w2>2000</td> <td height=30 width=100 id=w2>2001</td> <td height=30 width=100 id=w2>2002</td> <td height=30 width=100 id=w2>2003</td> </tr> <tr> <td rowspan=3 id=w1>计算机</td> <td id=w1>硬件</td> <td id=w2>74.2</td> <td id=w2>76.3</td> <td id=w2>81.6</td> <td id=w2>86.4</td> <td id=w2>90.0</td> </tr> <tr> <td id=w1>软件</td> <td id=w2>31.3</td> <td id=w2>33.8</td> <td id=w2>36.8</td> <td id=w2>40.0</td> <td id=w2>50.0</td> </tr> <tr> <td id=w1>服务</td> <td id=w2>60.2</td> <td id=w2>63.9</td> <td id=w2>68.7</td> <td id=w2>73.6</td> <td id=w2>80.0</td> </tr> <tr> <th height=30 width=150 colspan=2 id=w1>通信</th> <td id=w2>190.0</td> <td id=w2>202.7</td> <td id=w2>217.5</td> <td id=w2>235.1</td> <td id=w2>220.0</td> </tr> </table> </center> </body> </html> 一个高度是50.其余的都是30,按说应该是一样的啊
追问:恩,会吸取教训的,关键问题是,上面的代码解释出来确确实实是显示正确的,源代码就是这个样子,所以我正是我困惑的地方。。。
答案:id不能重复。下面应该用class。
其他:只是就你这个例子说    height=50  你自己设的50px  其他的30px  当然不一样了   写的代码没有意义  这个你用table不错  但是xhtml不是这么用的  可以在主table上设一个id就行 下面的元素直接引用   不能都设成id   好好学习一下基础是关键 <th colspan=2 height=30 width=150 id=w1>类别</th>                      把你的那个50改成30就行。你写了50,当然和下面30不一样。 其实我想说ID用两次可以原谅  用这么多次就不可以原谅了  把
#w1 {font-family:幼圆;font-size:15px;font-weight:bolder;text-align:center}
#w2{font-family:黑体;font-size:15px;font-weight:bold}
改成
.w1 {font-family:幼圆;font-size:15px;font-weight:bolder;text-align:center}
.w2{font-family:黑体;font-size:15px;font-weight:bold}
然后把所有的ID改成CLASS 

上一个:精通CSS和PHP的进来看看
下一个:急!用DW 里面CSS 定位我不想换行为什么会换行?右边的选相对上不到左边的这一行里面,选绝对就跑到左上角

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,