noobstar Posted September 19, 2009 Share Posted September 19, 2009 My problem is this as odd as it may sound I've honestly never needed to use this and now when I do its a real noodle scratcher. I got 2 divs, example: <div>This is some text</div> <div>This is some text too</div> The thing I want to do is keep both divs on the same line as well as move the second div to the right side. Now putting both divs inline is easy however, if I use the inline the float on the second div doesn't work properly it sort of nudges it one line down. Please if anyone has a better method in doing this I could really use the help in this. Thank you very much in advance for any help what so ever Quote Link to comment https://forums.phpfreaks.com/topic/174766-solved-two-divs-inlined-one-goes-left-the-other-right-driving-me-nuts/ Share on other sites More sharing options...
sticks464 Posted September 19, 2009 Share Posted September 19, 2009 You don't have to use div's to do this. <p class="test"><span>This is some left text </span>This is some right text</p> .test{ background:white; border:1px solid #000; color: #000000; text-align:right; padding:10px; white-space:nowrap; } .test span{float:left;width:5em;text-align:left;} If you want either side text to wrap, remove white-space:nowrap; If the text is images, replace the text with the image path, width and height. Or you can make one side text and the other side an image. Remove any css not needed ie. background, border. Quote Link to comment https://forums.phpfreaks.com/topic/174766-solved-two-divs-inlined-one-goes-left-the-other-right-driving-me-nuts/#findComment-921041 Share on other sites More sharing options...
jcombs_31 Posted September 19, 2009 Share Posted September 19, 2009 My problem is this as odd as it may sound I've honestly never needed to use this and now when I do its a real noodle scratcher. I got 2 divs, example: <div>This is some text</div> <div>This is some text too</div> The thing I want to do is keep both divs on the same line as well as move the second div to the right side. Now putting both divs inline is easy however, if I use the inline the float on the second div doesn't work properly it sort of nudges it one line down. Please if anyone has a better method in doing this I could really use the help in this. Thank you very much in advance for any help what so ever Why not just float div 1 left, div 2 right? Quote Link to comment https://forums.phpfreaks.com/topic/174766-solved-two-divs-inlined-one-goes-left-the-other-right-driving-me-nuts/#findComment-921290 Share on other sites More sharing options...
noobstar Posted September 20, 2009 Author Share Posted September 20, 2009 Thank you very much for the point in the right direction sticks464 I appreciate this greatly! Regards what jcombs_31 said, both divs are inside another div which has a background colour attached (I failed to mention this, sorry about that) when both divs are floated left and right the div container they are in doesn't auto size the height that's why i was trying to find out if there is another method in doing this. Again thank you very much Quote Link to comment https://forums.phpfreaks.com/topic/174766-solved-two-divs-inlined-one-goes-left-the-other-right-driving-me-nuts/#findComment-921662 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.