Home  >  Q&A  >  body text

javascript - The right column has a fixed width, and the left column is adaptive and has a minimum width

The right column has a fixed width and the left column is adaptive. However, when the window shrinks to a certain extent, the left column will no longer become smaller. If I want to achieve this effect, how should I lay it out?

phpcn_u1582phpcn_u15822720 days ago948

reply all(3)I'll reply

  • phpcn_u1582

    phpcn_u15822017-05-31 10:41:00

    The min-width of your left column: 300px; of course it will not get smaller. In fact, the simplest way to write it is:

    .left{
        float:left;
        display:inline-block;
        ...
    }
    .right{
        width: 600px;
        ...
    }

    And is this the problem? Why don't you see the problem?

    Follow up:

            .wrapper{
                width:100%;
                position:relative;
                overflow: scroll;
                min-width: 900px;
            }
            .left{
                min-width: 300px !important;
                position: absolute;
                right: 600px;
                background-color: yellow;
                height:500px;
                width: 100%;
            }
            .right{
                width: 600px;
                height:500px;
                float: right;
                background-color: red;
            }

    This should meet your needs, but I don’t know how you want to present the final size less than 900px, so I just use the scroll bar

    reply
    0
  • 某草草

    某草草2017-05-31 10:41:00

    <p class="wrapper">
        <p class="left"></p>
        <p class="right"></p>
    </p>
    
    .wrapper{
        position:relative;
        height:auto;
        padding-right: 600px;
        min-width: 900px;
        -webkit-box-sizing:border-box ;
        box-sizing:border-box ;
    }
    
    .right{
        position:absolute;
        right:0px;
        top:0px;
        width: 600px;
        min-height: 100%;
        height:auto;
        background: #000;
    }
    
    .left{
        position: relative;
        background: #c0c0c0;
        height: 400px;
    }
    

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-05-31 10:41:00

    .con(.l,.r)
    .con
    display:flex;
    flex-wrap:nowrap;
    width:100%;
    height:xpx;
    .l
    ....
    .r
    ... ..
    You should be able to understand it
    But it’s up to you to set the fixed width
    flex is actually better to use proportions

    reply
    0
  • Cancelreply