CSS: how to position element in lower right?

后端 未结 2 2166
忘了有多久
忘了有多久 2020-12-12 17:34

I am trying to position the text element \"Bet 5 days ago\" in the lower right-hand corner. How can I accomplish this? And, more importantly, please explain so I can conqu

2条回答
  •  死守一世寂寞
    2020-12-12 18:29

    Lets say your HTML looks something like this:

    Bet 5 days ago

    Then, with CSS, you can make that text appear in the bottom right like so:

    .box {
        position:relative;
    }
    .bet_time {
        position:absolute;
        bottom:0;
        right:0;
    }
    

    The way this works is that absolutely positioned elements are always positioned with respect to the first relatively positioned parent element, or the window. Because we set the box's position to relative, .bet_time positions its right edge to the right edge of .box and its bottom edge to the bottom edge of .box

提交回复
热议问题