html表格颜色代码怎么写

html表格颜色代码怎么写,第1张

下面的例子指定边框的颜色,和th元素的文本和背景颜色:

例<html>

<head><style>

table, td, th

{

border:1px solid green

}

th

{

background-color:green

color:white

}

</style></head><body>

<table>

<tr>

<th>Firstname</th>

<th>Lastname</th>

<th>Savings</th>

</tr>

<tr>

<td>Peter</td>

<td>Griffin</td>

<td>$100</td>

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

可以用 js 控制也可以使用css实现

1:使用 js的写法

<span  onmouseover="this.style.color='#ffffff'" onmouseout="this.style.color='#000000'"  style="color:#000000">文字</span>

设置初始的颜色为黑色。添加鼠标over事件,当鼠标移动到文字上面时变为白色,当鼠标移走时恢复为原来的颜色。

2:使用css 控制的写法为:

<a href="#">asdfasdfsdf</a>

a{color:#000000}

a:hover{color:#ffffff}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/7214003.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-03
下一篇 2023-04-03

发表评论

登录后才能评论

评论列表(0条)

保存