Chapsterj Chapsterj - 5 months ago 8x
HTML Question

position relative and right property

I always thought by setting the div to relative and right 0 would position the div all the way to the right, if its parent was 100% width. Apparently I'm wrong and only absolute works like that. So is there no way to make it work with relative?


You have to set the parent to be relative, and it's child to absolute positioning.

  position: relative;
  width: 100%;
  position: absolute;
  width: 200px;
  height: 200px;
  background: red;

‚Äč Like here: