Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Position a div to bottom left

Tags:

html

css

How to move the inside div sqrBall to the bottom left of the parent div container. Here is the HTML code:

<div class="container">
    <div class="sqrBall">

    </div>
</div>

Here is the CSS:

.container{
        width: 500px;
        height: 500px;
        border: 1px solid black;
        margin: 0 auto;
    }
    .sqrBall{
        width: 10px;
        height: 10px;
        background-color: blue;

    }

Here is a DEMO

like image 241
iJade Avatar asked Sep 17 '25 08:09

iJade


2 Answers

You can use absolute positioning on the inner element if the parent element has relative positioning. for example:

.container{
    width: 500px;
    height: 500px;
    border: 1px solid black;
    margin: 0 auto;
    position:relative;
}

.sqrBall{
    width: 10px;
    height: 10px;
    background-color: blue;
    position:absolute;
    bottom:0;
    left:0;
}

n.b. if the parent isn't positioned relatively, the inner element will be positioned to the bottom left of the body, not its parent. (at least in this example)

like image 82
atmd Avatar answered Sep 18 '25 21:09

atmd


try this demo Fiddle

.sqrBall {
width: 10px;
height: 10px;
 background-color: blue;
 position: absolute;
 top: 98%;
 left: 0;
   }
.container
{
position:relative;
}
like image 28
priya786 Avatar answered Sep 18 '25 21:09

priya786