css怎么实现滑动图片效果?
下面给大家举一个简单的css图片滑动效果示例(自下而上滑动):
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>css怎么实现图片滑动</title> <style type="text/css"> img{ height: 200px; width: 200px; } .slider { overflow-y: hidden; max-height: 500px; /* 最大高度 */ background: pink; height: 200px; width: 200px; /* Webkit内核浏览器:Safari and Chrome*/ -webkit-transition-property: all; -webkit-transition-duration: .5s; -webkit-transition-timing-function: cubic-bezier(0, 1, 0.5, 1); /* Mozilla内核浏览器:firefox3.5+*/ -moz-transition-property: all; -moz-transition-duration: .5s; -moz-transition-timing-function: cubic-bezier(0, 1, 0.5, 1); /* Opera*/ -o-transition-property: all; -o-transition-duration: .5s; -o-transition-timing-function: cubic-bezier(0, 1, 0.5, 1); /* IE9*/ -ms-transition-property: all; -ms-transition-duration: .5s; -ms-transition-timing-function: cubic-bezier(0, 1, 0.5, 1); } .slider.closed { max-height: 0; } </style> </head> <body> <div style="height: 200px; width: 200px; border: 1px solid #ccc;"> <div class="slider" id="slider"> <img src="2.webp"> </div> </div> <button onclick="document.getElementById('slider').classList.toggle('closed');">点击试试</button> </body> <html>
效果图:
更多web开发知识,请查阅 HTML中文网 !!
以上就是css怎么实现滑动图片效果?的详细内容,更多请关注易知道|edz.cc其它相关文章!