Resize a DIV when its text changes
- by Antonios
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.