鼠标经过切换背景图片,电脑端正常,但是移动端连背景图片都不显示,怎么回事?在线急等 20
.changqi01{background:url(../images/changqi01.png)no-repeatcenter;width:108px;height:...
.changqi01{
background:url(../images/changqi01.png) no-repeat center;
width:108px;
height:108px;
display:block;
}
.changqi02{
background:url(../images/changqi02.png) no-repeat center;
width:108px;
height:108px;
display:block;
}
<div class="changqi01" onMouseOver="this.className='changqi02'" onMouseOut="this.className='changqi01'">
</div> 展开
background:url(../images/changqi01.png) no-repeat center;
width:108px;
height:108px;
display:block;
}
.changqi02{
background:url(../images/changqi02.png) no-repeat center;
width:108px;
height:108px;
display:block;
}
<div class="changqi01" onMouseOver="this.className='changqi02'" onMouseOut="this.className='changqi01'">
</div> 展开
1个回答
展开全部
改下CSS代码:
.changqi01 {
background:url(../images/changqi01.png) no-repeat center;
width:108px;
height:108px;
}
.changqi01:hover {
background-image:url(../images/changqi02.png);
}
然后去掉div的onMouseOver和onMouseOut事件,这类切换背景图片的效果直接用纯CSS就能搞定,用不着JS。
更多追问追答
追问
这样修改,电脑端是没有问题的,但是手机端背景图片都没有显示了
追答
是不是背景图片太大溢出了?加一条: background-size: 100% 试试
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询