how to place last div into right top corner of parent div? (css)

前端 未结 5 1038
迷失自我
迷失自我 2020-12-14 05:35

Can I somehow use CSS to place the block2 in top right corner of block1?


Context :

  • block2
5条回答
  •  有刺的猬
    2020-12-14 06:09

    .block1 {
        color: red;
        width: 100px;
        border: 1px solid green;
        position: relative;
    }
    
    .block2 {
        color: blue;
        width: 70px;
        border: 2px solid black;
        position: absolute;
        top: 0px;
        right: 0px;
    }

    text

    text2

    block2

    Should do it. Assuming you don't need it to flow.

提交回复
热议问题