jstacks
jstacks

Reputation: 2437

CSS: float within parent with no defined width

Please see the fiddle below to see the code and result:

http://jsfiddle.net/jhacks/nnZWB/7/

I am trying to get two divs to float:right within their parent div that doesn't have a defined width. It works if I set a defined width, but as one of the children divs needs to have a variable width, I simply want the parent div to just stretch to fit the children divs. However, as you can see from the fiddle, they don't want to float horizontally for me.

I've tried adding a few different styles (e.g. overflow:hidden) but can't get it to work.

Any and all help is appreciated. Thanks!

Upvotes: 0

Views: 477

Answers (2)

My Head Hurts
My Head Hurts

Reputation: 37665

If the problem you are refering to is within the div topProfile then you just need to add float: right to topName.

If this is not the problem then you might have to include an image to help represent how you would like your layout to look.

Upvotes: 1

Will
Will

Reputation: 20235

Move the topProfilePic div inside the topName div.

<div id="topName">
    <div id="topProfilePic">    
        <div id="pic"></div>    
    </div>
    <a class="topText" href="name.html">Your Name Here</a>
</div>

http://jsfiddle.net/nnZWB/8/

Upvotes: 1

Related Questions