[css] 剩余宽度自适应

calc(100% - 200px);
注意有空格才能生效

DOCTYPE html>
<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>Documenttitle>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .red {
            height: 200px;
            background-color: rgb(151, 45, 45);
            width:200px;
            float: left;
        }

        .green {
            height: 200px;
            background-color: rgb(13, 226, 13);
            width: calc(100% - 200px);
            float: left;
        }
    style>
head>

<body>
    <div class="red">
        红色
    div>
    <div class="green">
        绿色
    div>
body>

html>

你可能感兴趣的:(#,css)