Jump to content

[SOLVED] Two divs inlined one goes left the other right (driving me nuts)


noobstar

Recommended Posts

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 :)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.