Search code examples
htmlcsscss-positionautogrow

Is it possible to grow a div if it has relative position element?


For every element inside a div it grows it's width , however when we placed a positioned element , here the error message is positioned to relative and has top of 3px. As it is showing container isn't growing. If I use

overflow: hidden; /* the message will be cut off */

How to fix this problem, am I missing any hacks. One way that I can do it growing it's height manually. However I think it isn't the most elegant solution, what if my content changes then I have re-calculate the height again.

Auto grow container if it has a positioned element.


Solution

  • Fixed it, thank you all for your help and support.

    .invalid-msg {
       display: block;
       max-width:234px;
       margin-top:3px;
    }