Good evening!

There is such a block:

<ul> <li id="parent"> <a href="#">test</a> <ul class="child"> <li id="child-elem">test-child</li> </ul> </li> </ul> 

The #parent width auto block, the .child position absolute block, how to make the width to the # child-elem block, like the #parent block (width inherit does not help)?

Thanks for attention.

    1 answer 1

    Set the absolute elements left and right to zero: http://jsfiddle.net/5uZLh/1/ . Once again I remind you that absolutely and fixedly positioned elements fall out of the general flow, so they should be avoided altogether.

    • one
      only fixed ones fall out; the absolute ones are very conveniently positioned relative to the relative parent. - zb '
    • @eicto, also fixed in place are positioned, if they are not set bindings. And about falling out - you see an overlap here: jsfiddle.net/6LN3N ? - etki
    • I’m generally talking about “avoid”, you need to understand what you’re doing and that’s all :) an absolutely positioned element, of course, doesn’t affect anyone but its descendants, and its position is relative to either the document or the ancestor with position: relative; about fixed too, here's how will you output something in the middle of the screen, in the case of a scrolled table? will you build a relative element, having previously found with js which thread the element on the screen, its position relative to the window and the document, and moving the fields, will you try to draw it on the screen? - zb '
    • @eicto are you talking about at all? - etki
    • one
      @Fike, here [another example] [1], by the way, just wrote yesterday. @eicto, "do not make up the tables" - yes ... Somehow, they tried to prove to me that the playing field of 10x10 cells must be recruited from ten divs containing a hundred spans inside, because "table layout is outdated." [1]: hashcode.ru/questions/297703#297747 - Risto