Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-01-2009, 05:32 PM   PM User | #1
sphinx1994
New Coder

 
Join Date: Jan 2009
Posts: 84
Thanks: 5
Thanked 0 Times in 0 Posts
sphinx1994 has a little shameless behaviour in the past
keeping this on the same line?

hello,

I want some text on the left , and some on the right, but on the same line, because when i use this code it puts the first bit of text on 1 line, and the next bit on the right but on the second line, how can i fix?

Thanks

Code:
<div align="left"><span class="copy">On the left</span>
<div align="right"><span class="copy">I want this aligned right but on the same line, not on the line below?</span>
sphinx1994 is offline   Reply With Quote
Old 05-01-2009, 07:39 PM   PM User | #2
ajhauser
Regular Coder

 
ajhauser's Avatar
 
Join Date: Nov 2007
Location: Earlville. It's where Earls come from.
Posts: 224
Thanks: 73
Thanked 1 Time in 1 Post
ajhauser is an unknown quantity at this point
You need to at least add a class defining the width of your div, or you could float the top div left and the bottom div right - but make sure to check it in several browsers because off the top of my head I know IE and FFox would handle this a little different, but I'm not sure how.

If this is a list of data and is a valid use for a table, then use a table.

I think the main message for designers is to get away from tables for layout purposes, but they are fine for diaplaying content as long as it makes sense to use them.
ajhauser is offline   Reply With Quote
Old 05-02-2009, 02:10 AM   PM User | #3
Excavator
Master Coder


 
Excavator's Avatar
 
Join Date: Dec 2006
Location: Alaska
Posts: 9,410
Thanks: 22
Thanked 1,765 Times in 1,749 Posts
Excavator has a spectacular aura aboutExcavator has a spectacular aura aboutExcavator has a spectacular aura about
Hello sphinx1994,
You don't close your divs and I'm not so sure they are needed anyway. If you are trying to do a 2 column layout then it might be done like this demo - http://nopeople.com/CSS/equal_length_columns/index.html

If it's just two lines of text then the spans should be enough markup to control it.
Try it like this -
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
html, body {
	font: 14px "Comic Sans MS";
	background: #FC6;
	text-align: center;
}
* {
	margin: 0;
	padding: 0;
	outline: none;
	border: none;
}
#container {
	width: 800px;
	margin: 30px auto;
	background: #999;
	overflow: auto;
}
.left {
	float: left;
}
.right {
	float: right;
}
</style>
</head>
<body>
    <div id="container">
		<span class="left">On the left</span>
		<span class="right">I want this aligned right but on the same line, not on the line below?</span>
    <!--end container--></div>
</body>
</html>
__________________
Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad
Excavator is offline   Reply With Quote
Old 05-02-2009, 08:39 AM   PM User | #4
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Quote:
I want some text on the left , and some on the right, but on the same line, because when i use this code it puts the first bit of text on 1 line, and the next bit on the right but on the second line, how can i fix?
Code:
<div ><span >On the left</span>
<span>I want this aligned right but on the same line, not on the line below?</span>
</div>
?
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 05-02-2009, 08:43 AM   PM User | #5
saifu
New to the CF scene

 
Join Date: May 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
saifu is an unknown quantity at this point
pls close the div

<div align="left"><span class="copy">On the left</span></div>
<div align="right"><span class="copy">I want this aligned right but on the same line, not on the line below?</span></div>

try this.....
saifu is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:06 AM.


Advertisement
Log in to turn off these ads.