<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script type="text/javascript" src = "img/"></script>
</head>
<body>
<style type="text/css">
.contact{width: 100%;height: auto;padding: 4vw 0;background: #1975FF;} /*vw是一种视窗单位,也是相对单位。相对于视口的宽度,视口被均分为100单位的vw。*/
.wechat_code{width: 100%;text-align: center;}
.wechat_code img{width: 40vw;height: auto;}
.wechat_code p{font: 4vw/1 "微软雅黑";color: #fff;}
</style>
<div class="contact">
<div class="wechat_code">
< img id="img" src= "img/1.jpg"/>
<p>关注微信</p >
</div>
</div>
<script>
window.οnlοad=function(){
let num = parseInt(Math.random()*4,10)+1
var img = document.getElementById("img");
document.getElementById("img").src="img/"+num+".jpg";
}
</script>
</body>
</html>