coldkill Posted July 23, 2008 Share Posted July 23, 2008 Hello all, wondering if this is possible and if so how to do it. Basically I've got some text within a div, I want that div to scale to what's inside of it. I tried using display: compact to no avail. Any thoughts? Thanks, Cold Quote Link to comment https://forums.phpfreaks.com/topic/116104-solved-having-a-div-take-its-width-from-its-contents/ Share on other sites More sharing options...
TheFilmGod Posted July 23, 2008 Share Posted July 23, 2008 The only way to do this is to use the float property. This is ideal if you want the content to go to one side, either left or right. But if you want to center that content, it is impossible since no "float: center;" exists. A table would work here as a charm, but of course I would never give in to such stupidity. Quote Link to comment https://forums.phpfreaks.com/topic/116104-solved-having-a-div-take-its-width-from-its-contents/#findComment-597078 Share on other sites More sharing options...
secoxxx Posted July 23, 2008 Share Posted July 23, 2008 width:auto; Quote Link to comment https://forums.phpfreaks.com/topic/116104-solved-having-a-div-take-its-width-from-its-contents/#findComment-597085 Share on other sites More sharing options...
coldkill Posted July 23, 2008 Author Share Posted July 23, 2008 Float worked, it shouldn't be a problem with getting it in the right position, it's only for a navigation menu after all. width: auto; didn't work however. Thanks for the help, Cold Quote Link to comment https://forums.phpfreaks.com/topic/116104-solved-having-a-div-take-its-width-from-its-contents/#findComment-597527 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.