• css:两栏三栏布局


    两栏布局左边固定右边自适应

    在这里插入图片描述

    1、浮动方式

    DOCTYPE html>
    <html lang="en">
    <head>
        <style>
            .left {
                width: 200px;
                height: 200px;
                float: left;
                background-color: blue;
            }
            .right {
                margin-left: 200px;
                height: 200px;
                background-color: red;
            }
        style>
    head>
    <body>
        <div class="father">
            <div class="left">div>
            <div class="right">div>
        div>
    body>
    html>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24

    2、定位方式

    DOCTYPE html>
    <html lang="en">
    <head>
        <style>
            .father {
                position: relative;
                height: 200px;
            }
            
            .left {
                position:absolute;
                width: 200px;
                height: 100%;
                background-color: blue;
            }
    
            .right {
                position:absolute;
                height: 100%;
                left:200px;
                right: 0;
                background-color: red;
            }
        style>
    head>
    <body>
        <div class="father">
            <div class="left">div>
            <div class="right">div>
        div>
    body>
    html>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32

    3、flex方式

    DOCTYPE html>
    <html lang="en">
    <head>
        <style>
            .father {
                height: 300px;
                width: 100%;
                display: flex;
            }
    
            .left {
                width: 300px;
                height: 100%;
                background-color: blue;
            }
    
            .right {
                flex: 1;
                height: 100%;
                background-color: red;
            }
        style>
    head>
    <body>
        <div class="father">
            <div class="left">div>
            <div class="right">div>
        div>
    body>
    html>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30

    三栏布局左右固定中自适应

    在这里插入图片描述

    1、浮动方式

    DOCTYPE html>
    <html lang="en">
    <head>
        <style>
            .father{
                height: 50px;
            }
            .left,.right,.main {
                height: 100%;
            }
    
            .left {
                width: 200px;
                float: left;
                background-color: red;
            }
    
            .main {
                margin-left: 200px;
                margin-right: 200px;
                background-color: blue;
            }
    
            .right {
                float: right;
                width: 200px;
                background-color: yellow;
            }
        style>
    head>
    <body>
        <div class="father">
            <div class="left">div>
            <div class="right">div>
            <div class="main"> div>
        div>
    body>
    html>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38

    2、定位方式

    DOCTYPE html>
    <html lang="en">
    <head>
        <style>
            .father{
                position: relative;
                height: 50px;
            }
            .left,.right,.main {
                position: absolute;
                height: 100%;
            }
    
            .left {
                left: 0;
                width: 200px;
                background-color: red
            }
    
            .main {
                left: 200px;
                right: 200px;
                background-color: blue
            }
    
            .right {
                right: 0;
                width: 200px;
                background-color: yellow
            }
        style>
    head>
    <body>
        <div class="father">
            <div class="left">div>
            <div class="right">div>
            <div class="main"> div>
        div>
    body>
    html>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40

    3、flex方式

    DOCTYPE html>
    <html lang="en">
    <head>
        <style>
            .father {
                display: flex;
                height: 50px;
            }
    
            .left,.right,.main {
                height: 100%;
            }
    
            .left {
                width: 200px;
                background-color: red
            }
    
            .main {
                flex: 1;
                background-color: blue
            }
    
            .right {
                width: 200px;
                background-color: yellow
            }
        style>
    head>
    <body>
        <div class="father">
            <div class="left">div>
            <div class="main"> div>
            <div class="right">div>
        div>
    body>
    html>
    ```
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
  • 相关阅读:
    Vue.js -Vuex 全局组件高效的数据通信方案
    UI线程和bitmap
    基于多智能体强化学习的出租车调度框架
    Hadoop_HDFS(二):Shell操作之文件的管理(上传下载删除等)
    ssm项目启动,控制台tomcat相关日志乱码
    php8.1-common : 依赖: libffi6 (>= 3.2) 但无法安装它(树莓派4B kali)
    *(长期更新)软考网络工程师学习笔记——Section 20 路由技术原理
    原生Hadoop3.X高可用配置方式
    Go语言基准测试(benchmark)三部曲之一:基础篇
    JAVA复习【11】单列集合Collection:ArrayList、 LinkedList、HashSet、TreeSet学习与使用
  • 原文地址:https://blog.csdn.net/weixin_43972437/article/details/127773426