当前位置: 首页> 科技> 能源 > 网页设计师介绍_如何推广中国文化_长沙优化网站哪家公司好_网站自动提交收录

网页设计师介绍_如何推广中国文化_长沙优化网站哪家公司好_网站自动提交收录

时间:2025/7/11 18:28:10来源:https://blog.csdn.net/PanDa____/article/details/146413573 浏览次数:0次
网页设计师介绍_如何推广中国文化_长沙优化网站哪家公司好_网站自动提交收录

实现功能:有水平3个DIV,左侧div和右侧div通过摁下鼠标左键修改div尺寸。

思路:设置一条drap-line线 并绑定方法,当摁下鼠标左键滑动时修改div尺寸,释放鼠标修改尺寸结束。

<!DOCTYPE html>
<html><head><meta charset="utf-8"><script src="jquery.js"></script><title></title></head><style>* {margin: 0;padding: 0;}body {display: flex;width: 100vw;height: 100vh;}.left,.right {width: 400px;background-color: aliceblue;height: 100%;}.center {flex: 3;background-color: antiquewhite;height: 100%;}.drap-line {width: 4px;height: 100%;background-color: brown;cursor: col-resize;}</style><body><div class="left"></div><div class="drap-line mr4"></div><div class="center"></div><div class="drap-line"></div><div class="right"></div><script>$(function(){resizeInit() ;});//左右两侧resize事件function resizeInit() {var isResizing = false;var DIV;var toward = 'left';$('body').on('mousedown','.drap-line',function (e) {isResizing = true;$(this).hasClass('mr4') ? (DIV = $('.left'), toward = 'left') : (DIV = $('.right'), toward = 'right');});$(document).on('mouseup',function (e) {isResizing = false;});$(document).on('mousemove',function (e) {if (!isResizing) return;var newWidth = 0;if (toward == 'left') {newWidth = e.pageX - DIV.offset().left;} else {newWidth = $(window).width() - e.pageX;}if (newWidth < 270) {newWidth = 270;} else if (newWidth > 900) {newWidth = 900;}DIV.width(newWidth);});};</script></body>
</html>

关键字:网页设计师介绍_如何推广中国文化_长沙优化网站哪家公司好_网站自动提交收录

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: