Resize a DIV when its text changes
        Posted  
        
            by 
                Antonios
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Antonios
        
        
        
        Published on 2012-10-04T16:02:14Z
        Indexed on 
            2012/10/04
            21:38 UTC
        
        
        Read the original article
        Hit count: 235
        
I wanted to build a custom html button without using any solution like bootstrap etc. but from scratch. I decided to use a div to build my button with very good results. However, when the text changes its length that does not mean the div will change its width as well. Should I approach this using javascript or is there a CSS solution I am missing. Apologies for missing code:
div {
    position: relative;
    width: 121px;
    height: 30px;
}
I need a minimum width and not a dynamic this is why I used a fixed one. In case there is not a CSS alternative then I will use a javascript approach.
© Stack Overflow or respective owner