Front-end - CSS one row divided into two columns
滿天的星座
滿天的星座 2017-05-27 17:44:16
0
6
1018

The design drawing stipulates that the length of the left block is 218px, but I have no way to determine the length of the next block in the same line. I hope that the last block can automatically fill the current line. Please advise

The current css style of the first block is:

   float: left;
   width: 218px;

Rendering:

滿天的星座
滿天的星座

reply all(6)
阿神
<style type="text/css">
        .row{
            display: flex;
            flex-direction: row;
            justify-content: flex-start;
            align-content: center;
            align-items: stretch;
            height: 50px;
        }
        .p1{
            width: 218px;
            flex-shrink: 0;
            background-color: #3c8dbc;
        }
        .p2{
            width: 1%;
            flex: 1;

            background-color: #5b9909;
        }
    </style>
    
    <p class="row">
        <p class="p1">123123123123123</p>
        <p class="p2">1232131</p>
    </p>

flex you deserve but remember to add the prefix

仅有的幸福

The block on the left can be positioned: absolute; absolutely positioned. The block on the right is directly margin-left: 218px; and then display:block;

PHPzhong

1. Parent {display:flex;}, right {flex:1}

2. Right {float:left;width:calc(100% - 218px);}

小葫芦

Last piece{

width:calc(100% - 218px);
float: left;

}

大家讲道理

The percentage is okay

过去多啦不再A梦

flex is a solution, but many times it is now required to be compatible with low-end browsers such as IE8, and flex is not possible.
Provide another solution:
Structure:

<p class="box">
    <p class="left">left</p>
    <p class="right">right</p>
</p>

Style:

.left, .right {
        height: 30px;
    }
    .left {
        float: left;
        width: 200px;
        background: #f90;
    }
    .right {
        background: #369;
        overflow: hidden;
    }
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template