Aligning text in the lower left corner inside a stylized element

How to make text that is INSIDE, this stylized element is aligned in the lower left corner? I want the text inside the box to be in the lower left corner of the window. The rest of the text should not be affected.

I am new to CSSand cannot understand.

HTML

<body>
    <h1>example text</h1>
    <article class="box" style="background-color: #2672EC">foo bar</article>
    <h1>example text</h1>
</body>

CSS

body {
    font-family: Verdana;
    font-size: 16px;
    color: black;
}

.box {
    height: 187px;
    width: 187px;
    margin-right: 5.5px;
    margin-left: 5.5px;
    margin-bottom: 5.5px;
    margin-top: 5.5px;
    color: white;

}

Here is the JSFiddle

http://jsfiddle.net/J9hT5/8/

+3
source share
2 answers

You can do this in two ways: either using CSS Positioning Technique, where you need to set the parent element position: relative;and the child element -position: absolute;

Demo (wrapping text with an elementspan)

.box > span {
    position: absolute;
    bottom: 0;
    left: 0;
}

Or using display: table-cell;withvertical-align: bottom;

( )

.box {
    height: 187px;
    width: 187px;
    margin-right: 5.5px;
    margin-left: 5.5px;
    margin-bottom: 5.5px;
    margin-top: 5.5px;
    color: white;
    display: table-cell;
    vertical-align: bottom;
}

, CSS,

margin-right: 5.5px;
margin-left: 5.5px;
margin-bottom: 5.5px;
margin-top: 5.5px;

margin: 5.5px 5.5px 5.5px 5.5px;

+2

:

<article class="box" style="background-color: #2672EC"><span class="bottom">foo bar</span>

:

.box {
    position: relative;
}
.bottom {
    position: absolute;
    bottom: 0;
    left: 0;
}

Fiddle

+1

All Articles