Using position:absolute while keeping it inside the document flow

后端 未结 3 611
情话喂你
情话喂你 2021-01-17 11:27

\"enter

It\'s a screenshot from a page currently I\'m building. I\'m trying to make su

3条回答
  •  情话喂你
    2021-01-17 11:56

    Adding position:absolute takes it out of the document flow, there's no way to keep it in it. But you can add padding-bottom equivalent to height of the button to the article container instead, which will prevent long text overrunning the button.

    .list-product-pat article {
        position: relative;
        min-height: 260px;
        padding-bottom:80px;
        -moz-box-sizing:border-box;
        box-sizing:border-box; 
    }
    

    http://jsfiddle.net/xrb5U/3/

    A separate issue is that two containers with different amount of texts will be different sizes (if one is larger than the min-height set). There's no easy fix for this in CSS positioning, you have to resort to Javascript, Flexbox or display:table-cell to keep the height of all them the same but each of them has their own issues too.

提交回复
热议问题