单元格变色和图片透明

本文介绍了一种使用CSS和HTML实现网页导航栏单元格颜色变化的方法,通过简单的代码即可达到鼠标悬停时背景色改变的效果,适用于创建交互式的网站导航。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>

用单元格变色的方法来做网页导航,在网上可以经常看到,但代码有简有繁,如果运用样式表来实现,将可以节约很多代码,特别是当有很多行需用这种效果时: 

1


 .aa
  { background-color:#aaa; color:#000 }
.bb 
  { background-color:#ccc; color:#000 }

<table width="200" border="0" cellspacing="1" cellpadding="0" >
<tr>
<td onmouseover="this.className='aa'" onmouseout="this.className='bb'" class="bb" >test </td>
<td onmouseover="this.className='aa'" onmouseout="this.className='bb'" class="bb" > test</td>
<td onmouseover="this.className='aa'" onmouseout="this.className='bb'" class="bb" > test</td>
</tr>
</table>
2

table#changecolor td a {
 width:100%;
 display:block;
 background-color:#ccc;
}
table#changecolor td a:hover {
 width:100%;
 background-color:#aaa;
}

<table id="changecolor" width="200" border="0" cellspacing="1" cellpadding="0" >
<tr>
<td ><a href="##">test</a>  </td>
<td ><a href="##">test</a>  </td>
<td ><a href="##">test</a>  </td>
</tr>
</table>

图片透明

<SCRIPT language=JavaScript1.2>
<!--
<!--
function high(which2){
theobject=which2
highlighting=setInterval("highlightit(theobject)",30)
}
function low(which2){
clearInterval(highlighting)
which2.filters.alpha.opacity=100
}
function highlightit(cur2){
if (cur2.filters.alpha.opacity>30)
cur2.filters.alpha.opacity-=10
else if (window.highlighting)
clearInterval(highlighting)
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->
</SCRIPT>

<IMG
            onmouseover=high(this) style="FILTER: alpha(opacity=100)"
            onmouseout=low(this)
            src="m/menu1.gif"
        border=0>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值