0

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!

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

I do have float:right assigned to topName. In regards to what I want to have happen... I'm looking to do something similar to say, Facebook or Twitter. Where they have a profile picture, your name, and a tools dropdown all side by side. The picture/name are within the same div to get them to link and hover the same.
Ok, well your float: right is on the anchor tag in your example. Moving it to topName works for me: jsfiddle.net/nnZWB/9
Doh. I didn't realize I had the anchor tag there. Thank you!
1

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/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.