html: <div class="homeWxq" onclick="openWxq(this)"></div> css: .homeWxq{ position: absolute; 19.5%; height: 35.6%; top: 50%; left: 40.1%; transform: translate(0,-50%); background-size: contain; background-position: center; background-repeat: no-repeat; background-image: url('../img/homeWxq.png'); pointer-events: auto; } .homeWxq:active{ position: absolute; 19.5%; height: 35.6%; top: 50%; left: 40.1%; transform: translate(0,-50%); background-size: contain; background-position: center; background-repeat: no-repeat; background-image: url('../img/homeWxqA.png'); pointer-events: auto; }