bodacydo
bodacydo

Reputation: 79299

How do I position a HTML element statically relative to another element?

Let's say I've this HTML:

<div id="article">
 <div id="article-text">...</div>
 <div id="slogan">Best Article Is Best</div>
</div>

How do I position #slogan always at top: 100 within #article?

I've tried setting absolute and relative position on #slogan and using top: 100 but if article text is bigger than 100px then #slogan will be pushed down.

Is there a way to position an element absolutely (or is it statically?) relative to its parent, no matter what content parent has?

Upvotes: 0

Views: 50

Answers (1)

smartrahat
smartrahat

Reputation: 5609

#article{
    position: relative;
}
#slogan{
    position: absolute;
    top: 100px;
}

Upvotes: 1

Related Questions