How to make an inline-block element fill the remainder of the line?

前端 未结 7 1618
抹茶落季
抹茶落季 2020-11-28 01:11

Is such a thing possible using CSS and two inline-block (or whatever) DIV tags instead of using a table?

The table version is this (borders added so you can see it):

7条回答
  •  隐瞒了意图╮
    2020-11-28 01:38

    See: http://jsfiddle.net/qx32C/36/

    .lineContainer {
        overflow: hidden; /* clear the float */
        border: 1px solid #000
    }
    .lineContainer div {
        height: 20px
    } 
    .left {
        width: 100px;
        float: left;
        border-right: 1px solid #000
    }
    .right {
        overflow: hidden;
        background: #ccc
    }
    left
    right


    Why did I replace margin-left: 100px with overflow: hidden on .right?

    EDIT: Here are two mirrors for the above (dead) link:

    • archive.is
    • web.archive.org
    • https://colinaarts-com.herokuapp.com/#making-room-for-floats/articles/the-magic-of-overflow-hidden

提交回复
热议问题