Wrox Programmer Forums
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 6th, 2004, 03:02 PM
Authorized User
 
Join Date: Oct 2003
Posts: 96
Thanks: 0
Thanked 0 Times in 0 Posts
Default align=right?

I would like to align this little "Close Window" javascript (below) to the right side of the page. Default is aligned to the left and I know how to center it but can't seen to figure out how to right align it.


<a href="javascript:top.close()">Close Window</a>




Thanks for your help :)


Rudy
__________________
Rudy
 
Old July 6th, 2004, 03:05 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

<span style="float:left;font-size:10pt;color:#ffffff"><a href='javascript:top.close()'>Close Window</a>

BTW, the tag is depreciated and I have replaced it with CSS.

HTH,

Snib

<><
 
Old July 6th, 2004, 03:30 PM
Authorized User
 
Join Date: Oct 2003
Posts: 96
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Snib
I changed it to float:right as I'm pretty sure that's what you wanted to type to make it align to the right side of the page. However, as the page opened, it moved it to the right and then placed it and all the other text on that page in the center. I don't know anything about CSS, do I need to enclose your code in <style></style> or anything?

How about doing this within a table?




Quote:
quote:Originally posted by Snib
 <span style="float:left;font-size:10pt;color:#ffffff"><a href='javascript:top.close()'>Close Window</a>

BTW, the tag is depreciated and I have replaced it with CSS.

HTH,

Snib

<><
Rudy
 
Old July 6th, 2004, 03:35 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

In a table you can set the align="right" attribute of a <td> to right-align a table cell.

You can also use a <div> with a style attribute:

<div style="text-align: right;">I am right-aligned</div>

Have you been able to work with my CSS based layout from the other post?

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Hailies Song by Eminem (Track 14 from the album: The Eminem Show) What's This?
 
Old July 6th, 2004, 03:45 PM
Authorized User
 
Join Date: Oct 2003
Posts: 96
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Imar,

Yes, this <div style="text-align: right;"><a href='javascript:top.close()'>Close Window</a></div> worked perfect.

Yes, I'm still working with the code you gave me for positioning my Web site and I think I can get it to work, at least I hope so.

Thanks again for all your help, I appreciate all the time you have taken putting up with me. I have been reading and working with a new book called, "Cascading Style Sheets" the designers edges, by Molly Holzschlag and Eric Meyer but a lot of it hasn't sunk in yet. I also need to do some studying on using TABLES. Any place you can suggest, books or links?

Anyway, thanks sooooo much!


Quote:
quote:Originally posted by Imar
 In a table you can set the align="right" attribute of a <td> to right-align a table cell.

You can also use a <div> with a style attribute:

<div style="text-align: right;">I am right-aligned</div>

Have you been able to work with my CSS based layout from the other post?

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Hailies Song by Eminem (Track 14 from the album: The Eminem Show) What's This?
Rudy
 
Old July 6th, 2004, 04:01 PM
Authorized User
 
Join Date: Oct 2003
Posts: 96
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar

2 questions:

Using the <div> tag, I guess text-align: right and left are used, but how about for centering, is it center or middle?

Also, I used the table to also get something to align right but is stayed aligned left, can you tell me what I did wrong...trying to learn.

<table border=0>
<tr>
<td align="right"><a href='javascript:top.close()'>Close Window</a>
</tr>
</td>
</table>


Quote:
quote:Originally posted by Imar
 In a table you can set the align="right" attribute of a <td> to right-align a table cell.

You can also use a <div> with a style attribute:

<div style="text-align: right;">I am right-aligned</div>

Have you been able to work with my CSS based layout from the other post?

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Hailies Song by Eminem (Track 14 from the album: The Eminem Show) What's This?
Rudy
 
Old July 6th, 2004, 04:08 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Quote:
quote:Using the <div> tag, I guess text-align: right and left are used, but how about for centering, is it center or middle?
It's center.

<div style="text-align:center">text</div>

HTH,

Snib

<><
 
Old July 6th, 2004, 04:16 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Re 1: The best place for these kind of lookups is either an IDE like Dreamweaver (that lists all the values), or better yet the W3C site:

http://www.w3.org/Style/CSS/

and this one in particular:

http://www.w3.org/TR/CSS21/text.html#alignment-prop

Re 2: Well, the table cell *did* right-align, but since the table has a width that is exactly the same as its inner content, you don't notice it is right-aligned.

In a two or more celled tabled, try something like this:
Code:
<table border="0" width="200">
<tr>
  <td width="100">I am left aligned</td>
  <td align="right"><a href='javascript:top.close()'>Close Window</a></td>
</tr>
</table>
Or align the entire table:
Code:
<table border="1" align="right" width="200">
<tr>
  <td width="100">I am left aligned</td>
  <td align="right"><a href='javascript:top.close()'>Close Window</a></td>
</tr>
</table>
Did you copy and paste your table example to this message? If so, you need to work on your nesting of tags. I noticed that in your other post as well.

Personally, I would drop tables for layout. CSS is much better suited for that purpose so you can use tables what they were designed for: presenting tabular data.
HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: People keep comin' around by Tindersticks (Track 2 from the album: Can our love) What's This?
 
Old July 6th, 2004, 04:26 PM
Authorized User
 
Join Date: Oct 2003
Posts: 96
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, this table you offered works great. As you pointed out, I hadn't defined a table width for this specific table, so I wasn't seeing the alignment work.

So I've learned a couple of new things today, important ones to me.
I will concentrate on the CSS as you advised.

Thank you,

Quote:
quote:Originally posted by Imar
 Re 1: The best place for these kind of lookups is either an IDE like Dreamweaver (that lists all the values), or better yet the W3C site:

http://www.w3.org/Style/CSS/

and this one in particular:

http://www.w3.org/TR/CSS21/text.html#alignment-prop

Re 2: Well, the table cell *did* right-align, but since the table has a width that is exactly the same as its inner content, you don't notice it is right-aligned.

In a two or more celled tabled, try something like this:
Code:
<table border="0" width="200">
<tr>
  <td width="100">I am left aligned</td>
  <td align="right"><a href='javascript:top.close()'>Close Window</a></td>
</tr>
</table>
Or align the entire table:
Code:
<table border="1" align="right" width="200">
<tr>
  <td width="100">I am left aligned</td>
  <td align="right"><a href='javascript:top.close()'>Close Window</a></td>
</tr>
</table>
Did you copy and paste your table example to this message? If so, you need to work on your nesting of tags. I noticed that in your other post as well.

Personally, I would drop tables for layout. CSS is much better suited for that purpose so you can use tables what they were designed for: presenting tabular data.
HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: People keep comin' around by Tindersticks (Track 2 from the album: Can our love) What's This?
Rudy
 
Old July 6th, 2004, 04:39 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Can I add one more thing to your list of today's learning experiences?
If you reply to a post, can you please not quote the entire message? Since this system is Web based, you always have the opportunity to read the entire thread. Quoting the entire previous message is a waste of bandwidth and makes the thread harder to read and follow.
IMO, the quote tags should be used exclusively to quote specific parts of a message you want to focus on.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: The Only Ones by Moloko (Track 8 from the album: Statues) What's This?





Similar Threads
Thread Thread Starter Forum Replies Last Post
Align to right not working Cyber Shiva HTML Code Clinic 4 July 19th, 2007 01:49 PM
EASY Q: Left-Align and Right-Align DIV? panuvin ASP.NET 1.0 and 1.1 Basics 0 December 16th, 2006 02:02 AM
Textbox align surendran Java GUI 2 August 24th, 2004 07:54 AM
Align text acko ASP.NET 1.x and 2.0 Application Design 2 January 9th, 2004 10:21 AM
align Center melvik C# 1 September 7th, 2003 04:50 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.