效果如图
代码如下
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<style>
div {
overflow: hidden;
-webkit-animation: ani 0.8s linear both;
animation: ani 0.8s linear both;
}
div img {
width: auto;
height: 100%;
}
@keyframes ani {
from {
max-width: 0;
}
to {
max-width: 25vw;
}
}
</style>
<body>
<div>
<img src="images/index/rcs_en_icon.png" alt="">
</div>
</body>
</html>
主要思路就是高度不变,控制宽度的变化