简体   繁体   English

具有纯 css 的可调整大小的 div

[英]resizable div with pure css

I want to implement resizable div with pure css and html (only).我想用纯 css 和 html (仅)实现可调整大小的 div。
this is my example code:这是我的示例代码:

<html>
<head>
    <link type="text/css" rel="stylesheet" href="./css/main.css" />
</head>
<body>
    <article>
        <section class="left">Left Side</section>
        <section class="center">Center</section>
        <section class="right">Right Side</section>
    </article>
</body>
</html>     

this is my scss:这是我的scss:

body {
    margin: 0;
    padding: 0;
    color: white;
}

article {
    background-color: yellow;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: auto auto auto;
    justify-content: start;
    section {
        background-color: #2c2c2c;
    }
    .left {
        resize: horizontal;
        overflow: auto;
    }
    .center {
        border-right: 1px solid rgba(134, 134, 134, 0.255);
        border-left: 1px solid rgba(134, 134, 134, 0.255);
        resize: horizontal;
        overflow: auto;
    }
    .right {
        // How can fix this ?!
    }
}     

How can style right side section to fill area between right side of Center section and right screen?如何设置right side部分的样式以填充Center部分右侧和右侧屏幕之间的区域?

Change your column structure to grid-template-columns: auto auto 1fr;将列结构更改为grid-template-columns: auto auto 1fr;

 body { margin: 0; padding: 0; color: white; } article { background-color: yellow; width: 100%; height: 100%; display: grid; grid-template-columns: auto auto 1fr; justify-content: start; } article section { background-color: #2c2c2c; } article.left { resize: horizontal; overflow: auto; } article.center { border-right: 1px solid rgba(134, 134, 134, 0.255); border-left: 1px solid rgba(134, 134, 134, 0.255); resize: horizontal; overflow: auto; background: green; } article.right { background: red; }
 <article> <section class="left">Left Side</section> <section class="center">Center</section> <section class="right">Right Side</section> </article>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM