CSS table column autowidth

前端 未结 4 1227
感情败类
感情败类 2020-12-02 07:45

Given the following how do i make my last column auto size to its content? (The last column should autosize-width to the content. Suppose i have only 1 li element it should

4条回答
  •  甜味超标
    2020-12-02 08:38

    You could specify the width of all but the last table cells and add a table-layout:fixed and a width to the table.

    You could set

    table tr ul.actions {margin: 0; white-space:nowrap;}
    

    (or set this for the last TD as Sander suggested instead).

    This forces the inline-LIs not to break. Unfortunately this does not lead to a new width calculation in the containing UL (and this parent TD), and therefore does not autosize the last TD.

    This means: if an inline element has no given width, a TD's width is always computed automatically first (if not specified). Then its inline content with this calculated width gets rendered and the white-space-property is applied, stretching its content beyond the calculated boundaries.

    So I guess it's not possible without having an element within the last TD with a specific width.

提交回复
热议问题