pc端兼容移动端-最基础

本文探讨了如何在不依赖viewport meta标签的情况下,实现PC端页面的自适应布局,通过CSS flexbox技术,使1024px宽度的盒子包含一个可伸缩的box1和一个固定宽度的box2,实现在不同设备上的响应式设计。

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

pc端适应移动端-基础布局

<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- <meta name="viewport" content="width=device-width, initial-scale=1.0"> -->
    <title>不使用viewpoint</title>
    <style>
        *{
            margin: 0;
            padding: 0;
            list-style: none;
        }
        html,body{
            width: 100%;
            height: 100%;
            background-color: yellowgreen;
        }
        .container{
            width: 100%;
            /* min-width: 1200px; */
            height: 100%;
            background-color: teal;
        }
        .box{
            display: flex;
            min-width: 1024px;
            height: 100%;
            background-color: tomato;
        }
        .box1{
            flex: 1;
            height: 100%;
            background-color: violet;
        }
        .box2{
            width: 200px;
            background-color: turquoise;
        }
    </style>
</head>

<body>
    <div class="container">
        <div class="box">
            <div class="box1">1</div>
            <div class="box2">2</div>
        </div>
    </div>
</body>
</html>```

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值