Take into account the height of the absolute elements inside the relative element

Is it possible for the height relative to the positioned element to adjust to the height of its child?


See demo


HTML:

Items:
<div id="love">
    <textarea id="magic"></textarea>       
</div>
Dung:​​

CSS

#love{
    position:relative;
    background:#eee;
    width:60px;
}
#magic{
    position:absolute;
    width:20px;
}

Conclusion:

Dungbombs!

+3
source share
1 answer

when you specify absolute positioning, you need to give it the coordinates

#magic{
    position:absolute;
    width:20px;   
}

you specify x pos and y pos as 0 and 0, the outer tag is configured according to the inner label // if you do not specify the width or height for the outer tag

#magic{
    position:absolute; 
    left:0; // x pos
    top:0; // y pos
    width:20px;
}
+2
source

All Articles