CSS HOVER 背景颜色盖住背景图片

2025-06-26 19:41:54
推荐回答(3个)
回答1:

#denglu:hover{background-color:#CCCCCC ;color:red;}

  这里你需要用background-color,因为用background的话你需要写上图片路径的,如果不写相当于没有背景图片。

回答2:

同时使用背景图片和背景颜色可以实现,需要如下代码:
.test{background:url("图片链接") center center no-repeat; background-color:#000;}


.test{background:url("图片链接") #000000 center center no-repeat;}

注意:
背景图片需要在背景颜色之前;

需要设置多个值时使用background,只需图片链接时可直接用background-img链接;

回答3:

背景图片加 z-index:-1