tags:

views:

36

answers:

4

I am trying to make a h2 header for sidebar widgets but I want the width of the div class to be whatever width the content becomes. It seems I can't just set a width because those headlines with longer content then shorter content makes it break.

http://mibsoftware.us/clients/raveis/

How can I simply make width stretch/change depending on the length of content there is? Any help would be greatly appreciated.

A: 

h2 { display: inline }

Litso
Don't forget to set the line-height to make sure the h2's are all the same height too, this seems to fail when I try it on your live example.
Litso
A: 

The best way to do this is to set display: inline;. Note, however, that in inline display, you lose access to some layout properties, such as manual height and vertical margins, but this doesn't appear to be a problem for your page.

Delan Azabani
yes when i set to `display:inline` i can't set a bottom margin which is desperately needed. thoughts?
HollerTrain
A: 

If display: inline; isn't working, try out display: inline-block;. :)

Kyle Sevenoaks
does using `display:inline` limit me from using `margin-bottom` commands? now that i'm using `display:inline` i can't add bottom margin to it! thoughts?
HollerTrain
Using just inline does, that's why I suggested using inline-block, this removes that limit.. afaik.
Kyle Sevenoaks
`inline block` makes it span 100% which is what I don't want
HollerTrain
+1  A: 

As far as I know, display: inline-block is what you probably need. That will make it seem like it's sort of inline but still allow you to use things like margins and such.

Svish
but it makes my div 100% in width which is what i don't need
HollerTrain
@HollerTrain: What browser are you using? Cause it works perfectly here. If I remove your `width` and `text-align`, and adds that `display:inline-block` on `h2.widgettitle`, I get the result you want.
Svish
By the way, if I were you, I would run the site through the http://validator.w3.org as well as try to slim it down quite a bit. I do not have a bad internet connection and not a slow computer, but your page took almost 1.5 minutes to load. You have for example some images that are a lot bigger than they need to be; around 200kB each. Install http://getfirebug.com if you haven't, open up its Net tab and reload your page (Ctrl+F5, probably)
Svish
ah you are right! must have been an issue with Firebug. you saved my day and taught me something (more valuable!)
HollerTrain