left and right align on the same line

J

John Salerno

If I have a div with some text in it (a date and a time), and I want the
date left-aligned (default) and the time right-aligned with the right
side of the div, how would I do that?

I put spans around the date and time and gave them each a class of .date
and .time, and for time I did:

..time {
text-align: right;
}

but that didn't do anything, so I figure maybe I'm not using the spans
correctly.
 
N

Neredbojias

With neither quill nor qualm, John Salerno quothed:
If I have a div with some text in it (a date and a time), and I want the
date left-aligned (default) and the time right-aligned with the right
side of the div, how would I do that?

I put spans around the date and time and gave them each a class of .date
and .time, and for time I did:

.time {
text-align: right;
}

but that didn't do anything, so I figure maybe I'm not using the spans
correctly.

You positioned the time within the span to the right of the span...
 
B

Beauregard T. Shagnasty

John said:
If I have a div with some text in it (a date and a time), and I want
the date left-aligned (default) and the time right-aligned with the
right side of the div, how would I do that?

I put spans around the date and time and gave them each a class of
.date and .time, and for time I did:

.time {
text-align: right;
}

You need to use floats. See the source of this page of mine.
http://k75s.home.att.net/banner.html
 
J

John Salerno

Beauregard said:
You need to use floats. See the source of this page of mine.
http://k75s.home.att.net/banner.html

Excellent! float left and right did what I needed. But a quick question:
before I did float: left for the date (since it was already left-aligned
anyway), I did float: right for the time, and this caused it to not only
be moved to the right, but also down a little so that it wasn't lined up
on the same line as the date. But after I added float:left for the date,
this moved the time back up and re-aligned them. Why would it do that?

Thanks again!
 
B

Beauregard T. Shagnasty

John said:
Excellent! float left and right did what I needed. But a quick
Whoohoo.

question: before I did float: left for the date (since it was already
left-aligned anyway), I did float: right for the time, and this
caused it to not only be moved to the right, but also down a little
so that it wasn't lined up on the same line as the date. But after I
added float:left for the date, this moved the time back up and
re-aligned them. Why would it do that?

Think of shoes. If you're only wearing one shoe, you may get some parts
dragging behind, eh?

Wear both shoes and walking proceeds normally. <lol>

Yeah, yeah, I know ... not the answer you wanted. I'd guess that when
you only take one part out of the normal flow, the regular content ..
well .. I'm too busy watching ski jumping ...
 
J

John Salerno

Beauregard said:
Think of shoes. If you're only wearing one shoe, you may get some parts
dragging behind, eh?

Wear both shoes and walking proceeds normally. <lol>

Yeah, yeah, I know ... not the answer you wanted. I'd guess that when
you only take one part out of the normal flow, the regular content ..
well .. I'm too busy watching ski jumping ...

LOL. Well, that last bit there actually makes some sense anyway! But
thanks for fixing the original problem! :)
 
J

Jim S.

hi, i was looking at your example, and i like it, am using dreamweaver 8 but
i noticed unless i write <span> manually, i can not seem to replicate your
example. (well almost, since what happens is, the div tag disappears but the
alignment happens)
do i really have to write <span> since even if i do that and apply a class
to it, it does not show like your code, so what am i doing wrong?

thanks if u answer this

jim
 
B

Beauregard T. Shagnasty

Jim said:
hi, i was looking at your example, and i like it, am using dreamweaver
8 but i noticed unless i write <span> manually, i can not seem to
replicate your example. (well almost, since what happens is, the div
tag disappears but the alignment happens)

I write code using a text editor, so I always create a span manually.
do i really have to write <span> since even if i do that and apply a
class to it, it does not show like your code,

Can you copy and paste, then modify with your content, in source mode or
whatever DW calls it?
so what am i doing wrong?

Using DreamWeaver? :)
thanks if u answer this

You're welcome.
..
 
J

Jim S.

thanks for replying, maybe another question :D
when do u usually use <span> ? i know when dreamweaver decides to :D but not
when i need to.

thanks again.
Jim
 
B

Beauregard T. Shagnasty

Jim said:
thanks for replying, maybe another question :D when do u usually use
<span> ? i know when dreamweaver decides to :D but not when i need
to.

I use span for markup of inline parts of content when there is no
semantic element that does it better.

If I wanted to <em>emphasize</em> something, I would not use span.

If I wanted to <span class="hot">change the color</span> of those words
....

..hot { background-color: transparent; color: red; }

If I wanted to float an image within a container, you've seen my banner
page.

I don't know of any WYSIWYMG apps that can do stuff like this reliably.
 
J

Jonathan N. Little

Jim said:
thanks for replying,

Please do not top post in UseNet, the flow of the 'conversation' get all
mixed up.

maybe another question :D
when do u usually use <span> ? i know when dreamweaver decides to :D but not
when i need to.

Another good reason to drop DW and learn HTML, then you will know what
elements to use and why.

A SPAN is for the demarcation of a portion of text for some distinction
without interruption of the flow of whole block of text. I.e., text
remains 'inline' as opposed to DIV that separates the text in a new block.

<snip>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top