Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a div's position inside another div to bottom right corner?

Tags:

html

css

In this example:

html

<div style="width:50%;overflow:hidden">  
        <div id="inboxHeader">
                    <div id="inboxCount"><p>Earth</p></div>

        </div>
    </div>

css

#inboxHeader{
        background-color:yellow;    
        height :300px;
        position: relative;
    }

    #inboxCount{
        position: absolute; 
        bottom: 0;
        float:right; 
    }

Earth is in the bottom left corner. So how can I shift it to the bottom right corner?

like image 310
prime Avatar asked Apr 01 '14 18:04

prime


2 Answers

Set right:0 instead of float:right

http://jsfiddle.net/8np2f/4/

like image 164
Frederik Spang Avatar answered Nov 19 '22 12:11

Frederik Spang


As it's an absolutely positioned element change float:right; for right: 0px;

If it was positioned relatively then you would need to float it to the right however absolute positioning removes the element from the flow of the DOM.

One caveat however, make sure the parent element has it's position set either to relative or absolute as required, or the child element could position itself against the highest in the DOM tree that has a position set.

like image 1
RemarkLima Avatar answered Nov 19 '22 10:11

RemarkLima