前两天无聊用css实现了一个擦玻璃的效果,今天我就来给大家说说这个效果是如何做的,如下图所示:
<html class=" -webkit-"> <head> <meta charset="UTF-8"> <link rel="apple-touch-icon" type="image/png" href="https://cpwebassets.codepen.io/assets/favicon/apple-touch-icon-5ae1a0698dcc2402e9712f7d01ed509a57814f994c660df9f7a952f3060705ee.png"> <meta name="apple-mobile-web-app-title" content="CodePen"> <link rel="shortcut icon" type="image/x-icon" href="https://cpwebassets.codepen.io/assets/favicon/favicon-aec34940fbc1a6e787974dcd360f2c6b63348d4b1f4e06c77743096d55480f33.ico"> <link rel="mask-icon" type="image/x-icon" href="https://cpwebassets.codepen.io/assets/favicon/logo-pin-8f3771b1072e3c38bd662872f6b673a722f4b3ca2421637d5596661b4e2132cc.svg" color="#111"> <title>css实现拖拽预览图片效果www.woaidaogu.com</title> <style> html { background: #ddd; height: 100%; width: 100%; } .picA { background-image: url(https://z3.ax1x.com/2021/08/17/fhJdpQ.png); background-size: cover; width: 650px; height: 340px; border: 5px solid #f0e5ab; border-radius: 3px; box-shadow: 0 0 1px #999, -2px 2px 3px rgba(0, 0, 0, 0.2); padding: 0; margin: 1rem auto; position: relative; overflow: hidden; } .picB { background-image: url(https://z3.ax1x.com/2021/08/17/fhJUfg.png); background-size: cover; height: 340px; position: absolute; top: 0; left: 0; min-width: 0; max-width: 650px; box-sizing: border-box; } .picB:before { content: "↔"; position: absolute; background: rgba(0, 0, 0, 0.5); font-size: 16px; color: white; top: 0; right: 0; height: 100%; line-height: 340px; } .resizeElement { resize: horizontal; overflow: scroll; opacity: 0; position: relative; top: 50%; left: 0px; height: 15px; max-width: 650px; min-width: 15px; width: 0; cursor: move; transform: scaleY(35); transform-origin: center center; animation: delta 5s normal ease-in-out 1s; } @keyframes delta { 30% { width: 0; } 60% { width: 350px; } 100% { width: 0; } } h1 { text-align: center; color: #2fb4e1; font-size: 2rem; line-height: 2rem; margin: 0; } </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script> <script> if (document.location.search.match(/type=embed/gi)) { window.parent.postMessage("resize", "*"); } </script> </head> <body translate="no"> <h1>PURE CSS SWITCH PIUTURE</h1> <div> <div> <div readonly="" style="width: 395px;"></div> </div> </div> <script src="https://cpwebassets.codepen.io/assets/editor/iframe/iframeRefreshCSS-4793b73c6332f7f14a9b6bba5d5e62748e9d1bd0b5c52d7af6376f3d1c625d7e.js"></script> <div id="xl_chrome_ext_{4DB361DE-01F7-4376-B494-639E489D19ED}" style="display: none;"> <div></div> <a id="xl_chrome_ext_download" href="javascript:;">下载视频</a> <a id="xl_chrome_ext_close" href="javascript:;"></a> </div> </body> </html>
通过以上内容我们知道了css如何实现拖拽预览图片效果?感谢您访问“我爱捣鼓(www.woaidaogu.com)”网站的内容,希望对大家有所帮助!引用本文内容时,请注明出处!谢谢合作!