How to align text / images to bottom / right / center / middle of container using project css frame?

Is there some simple way to align stuff in div containers to the right or bottom:

<div class="span-24 align-right last">Text appears on the right side of the layout</div>

      

or

<div class="span-2" id="lots-of-content"></div><div class="span-22 last bottom">Appears at bottom of container</div>

      

or

<div class="span-24 vertical-middle last">Middle of the container</div>

      

Here's an example of what I'm working on trying to position "topnav" below:

     <div class="container"> 
        <div class="span-16">
            <h1>Header</h1>
        </div>
        <div class="span-8 last vertical-middle">
            <div id="topnav" class="align-right"><input type="button" id="register" class="ui-button ui-state-default ui-corner-all" value="Register" /> or <button type="button" id="signin" class="ui-button ui-state-default ui-corner-all">Sign in</button></div>
        </div>
        <hr />
...
     </div>

      

+2


source to share


1 answer


Use position: absolute

. For example:

.align-right {
    position: absolute;
    right: 0;
}
/* Or, alternatively, */
.align-right {
    float: right;
}

.bottom {
    position: absolute;
    bottom: 0;
}
.vertical-middle {
    position: absolute;
    top: 50%;
}

      

Note that vertical-middle

this will center the top edge of the content, without the content itself.



Make sure the containing DIV

is equal position: relative

to force it to become the parent of the offset (with which the position of the children should be) RED. ... In other words, add the following rule:

.container {
    position: relative;
}

      

+3


source







All Articles