No.1 实现两列布局 一列定宽

本文介绍并演示了五种实现固定宽度侧边栏与剩余宽度主要内容布局的方法,包括使用Flexbox、浮动元素、绝对定位等技术手段。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<html>
    <head>
//方法1
        <style>
        /* .parent{
            display: fles;
            display: -webkit-flex;
        }
        .left-child{
            flex:0 100px;
            background: #22bd7a;
        }
        .right-child{
            flex:1;
            background: #f60;
        } */
        </style>
//方法2
        <style>
        /* .left-child{
            width: 100px;
            float:left;
            background: #F60;
        }
        .right-child{
            overflow: hidden;
            background: #22bd7a;
        } */
        </style>
//方法3
        <style>
        /* .left-child{
            width: 100px;
            float:left;
            background: #f60;
        }
        .right-child{
            margin-left: 100px;
            background: #22bd7a;
        } */
        </style>
//方法4 
        <style>
        /* .parent{
            position: relative;
        }
        .left-child{
            position: absolute;
            width: 100px;
            top: 0;
            left: 0;
            background: #f60;
        }
        .right-child{
            margin-left: 100px;
            background: #22bd7a;
        } */
        </style>
//方法5
        <style>
        .parent{
            position: relative;
            padding-left: 100px;
        }
        .left-child{
            position: absolute;
            left: 0;
            top: 0;
            width: 100px;
            background: #f60;
        }
        .right-child{
            top: 0;
            right: 0;
            background: #22bd7a;
        }
        </style>
    </head>
    <body>
        <div class="parent">
            <div class="left-child"></div>
            <div class="right-child"></div>
        </div>
    </body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值