Say you want to position something within its container, then the element you are trying to position needs to have:

position: absolute;

But the parent container can simply have:

position: relative;

So in full:

<div class="container">
    <div class="abs-position">
        Hello world!
    </div>
</div>

And then simple CSS:

.container {
    position: relative;
}

.abs-position {
    position: absolute;
    left: 100px;
    height: 200px;
}

Easy solution to an age old problem.

By admin

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.