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

前端 未结 7 1612
抹茶落季
抹茶落季 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:47

    You can use calc (100% - 100px) on the fluid element, along with display:inline-block for both elements.

    Be aware that there should not be any space between the tags, otherwise you will have to consider that space in your calc too.

    .left{
        display:inline-block;
        width:100px;
    }
    .right{
        display:inline-block;
        width:calc(100% - 100px);
    }
    
    
    

    Quick example: http://jsfiddle.net/dw689mt4/1/

提交回复
热议问题