-1

I am trying to position a div (C) inside another div (B) which is nested inside other div (A).

I want C, to be absolute positioned, at the top right corner of B. But, with the following code, it is nested at the top right corner of A.

<div>
  <div style="width: 500px; height: 500px; padding: 25px; background-color: aqua;">
    <div style="width: 200px; height: 100px; background-color: lime">
      <div style="position: absolute; top: 0; right: 0; width: 35px; height: 10px; background-color: red;"  />
    </div>
  </div>
</div>

Any ideas?

Raul
  • 2,673
  • 1
  • 15
  • 52

1 Answers1

2

give the element (B) a position: relative; and it will fix your problem.

position absolute is part of a parent - child relationship. you've specified the child, but you have to specify the parent too.

Spoochy
  • 321
  • 1
  • 7