纯css实现左右拖拽改变盒子大小

效果:
在这里插入图片描述

代码

<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
    <title></title>
    <style>
        body {
            background-color: black;
            color: white;
        }

        .column {
            overflow: hidden;
        }

        .column-left {
            height: 97VH;
            background-color: #111;
            position: relative;
            float: left;
        }

        .column-right {
            height: 97VH;
            padding: 16px;
            background-color: #111;
            box-sizing: border-box;
            overflow: hidden;
        }

        .resize-save {
            position: absolute;
            top: 0;
            right: 5px;
            bottom: 0;
            left: 0;
            padding: 16px;
            overflow-x: hidden;
        }

        .resize-bar {
            width: 200px;
            height: inherit;
            resize: horizontal;
            cursor: ew-resize;
            cursor: col-resize;
            opacity: 0;
            overflow: scroll;
        }

        /* 拖拽线 */
        .resize-line {
            position: absolute;
            right: 0;
            top: 0;
            bottom: 0;
            border-right: 2px solid #111;
            border-left: 1px solid #bbb;
            pointer-events: none;
        }

        .resize-bar:hover~.resize-line,
        .resize-bar:active~.resize-line {
            border-left: 1px dashed skyblue;
        }

        .resize-bar::-webkit-scrollbar {
            width: 100px;
            height: inherit;
            cursor: ew-resize;
            cursor: col-resize;
        }

        /* Firefox只有下面一小块区域可以拉伸 */
        @supports (-moz-user-select: none) {

            .resize-bar:hover~.resize-line,
            .resize-bar:active~.resize-line {
                border-left: 1px solid #bbb;
            }

            .resize-bar:hover~.resize-line::after,
            .resize-bar:active~.resize-line::after {
                content: '';
                position: absolute;
                width: 16px;
                height: 16px;
                bottom: 0;
                right: -8px;
                background: url(./resize.svg);
                background-size: 100% 100%;
            }
        }

        /*mobile*/
        @media screen and (max-width: 640px) {
            .main {
                -webkit-user-select: none;
                user-select: none;
            }
        }
    </style>
</head>

<body>
    <div class="column">
        <div class="column-left">
            <div class="resize-bar"></div>
            <div class="resize-line"></div>
            <div class="resize-save">
                左侧的内容,左侧的内容,左侧的内容,左侧的内容
            </div>
        </div>
        <div class="column-right">
            右侧的内容,右侧的内容,右侧的内容,右侧的内容
        </div>
    </div>
</body>

</html>

相关推荐

  1. css实现悬浮球组件

    2024-04-13 10:30:01       39 阅读
  2. css实现文字左右循环滚动播放效果

    2024-04-13 10:30:01       42 阅读
  3. 前端页面 贴边 盒子

    2024-04-13 10:30:01       32 阅读
  4. React实践

    2024-04-13 10:30:01       72 阅读
  5. React实践

    2024-04-13 10:30:01       66 阅读
  6. React实践

    2024-04-13 10:30:01       52 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-13 10:30:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-13 10:30:01       100 阅读
  3. 在Django里面运行非项目文件

    2024-04-13 10:30:01       82 阅读
  4. Python语言-面向对象

    2024-04-13 10:30:01       91 阅读

热门阅读

  1. docker简介和运行命令

    2024-04-13 10:30:01       40 阅读
  2. Docker一键安装Memos个人笔记

    2024-04-13 10:30:01       31 阅读
  3. C/C++ 读取配置文件的几种方式

    2024-04-13 10:30:01       37 阅读
  4. 【Django】必须登陆才能访问功能实现

    2024-04-13 10:30:01       39 阅读
  5. 【Vue 自定义事件】

    2024-04-13 10:30:01       35 阅读
  6. c语言中三个open,fopen,popen的区别

    2024-04-13 10:30:01       43 阅读
  7. 事件冒泡、事件捕获、事件委托

    2024-04-13 10:30:01       39 阅读
  8. 实现卡片中每一条数据key的右对齐

    2024-04-13 10:30:01       37 阅读
  9. FastAPI 是干啥的

    2024-04-13 10:30:01       37 阅读
  10. 使用React Context的一些优化建议

    2024-04-13 10:30:01       34 阅读
  11. 自定义注解加反射实现数据类型转换

    2024-04-13 10:30:01       33 阅读
  12. 博客永久链接与计数

    2024-04-13 10:30:01       35 阅读
  13. Android8.1 MTK平台 修改蓝牙默认名称

    2024-04-13 10:30:01       36 阅读