用css样式怎样实现鼠标放在背景图片上,背景图片的颜色改变?

如题所述

第1个回答  推荐于2016-10-27
给你2个解决方案:
1、
<div class="bg" onmouseover="this.className='bg_hover'" onmouseout="this.className='bg'"></div>

<style type="text/css">
.bg{ background:red; width:100px; height:50px;}
.bg_hover{ background:black; width:100px; height:50px;}
</style>

2、
<div class="bg" ></div>

<style type="text/css">
.bg{ background:red; width:100px; height:50px;}
.bg:hover{ background:black; width:100px; height:50px;}
</style>本回答被提问者采纳