Positioning absolut element on parenthood



  • How to position: absolute inside another element with position: absolute.

    If left, top, the element is slightly lower than the parent. I need to move it a little bit. By pointing left and top, the element can be arranged for the specified coordinates, but the connection with the parent is lost.

    And it's all done without JavaScript. There would be no question with JS.

    It's a little more detailed now. I might invent a bike, but I had to do a multi-level popup menu. Of course, I've been looking for solutions, but there's nothing right.

    It's now realised, literally, 2-3 small classes. The problem is, I'm gonna change the picture below the parent element by covering the rest. You can't change the position on the relative - then I'll replace it with the main menu. The coordinates can't be determined - they'repermanent.

    And again, without the use of JavaScript.

    Is that possible?



  • .parent-absolute{
        position: absolute; top: 50px; left: 50px;
        width: 150px;
        height: 150px;
        background: #ccc;
    }
    .child-relative{
        position: relative;
    }
    .child-absolute{
        position: absolute; top: 0; left: 0;
        width: 100px;
        height: 100px;
        background: #00f;
    }
    <div class="parent-absolute">
        <div class="child-relative">
            <div class="child-absolute">
                child-absolute
            </div>
        </div>
    </div>


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2