CSS Help (Yes, there's a reward)

F

Fahad

Guest
How would I align a table to the right of the page?
This one has me stumped, so if anyone can help me, I'll pay!
Thank you all!
 

sunils

New Member
Messages
2,266
Reaction score
0
Points
0
How would I align a table to the right of the page?
This one has me stumped, so if anyone can help me, I'll pay!
Thank you all!

Enclose the table inside this code.

<div align="right"></div>

Its so simple.

If you need further clarification, post the jist of the intended code which you want to right align.

Thank you,

All the best
 
F

Fahad

Guest
Thank you so much!
Payed
EDIT: Doesn't work.
HTML:
<div align="right"><TABLE WIDTH="150px" HEIGHT="100%" CELLPADDING=0 style="position: absolute; top: 150px;">
 <TR><TD WIDTH=1 BGCOLOR="black">
 <SPACER TYPE="block" WIDTH=1></TD>
 <TD>
	<a href="http://www.spreadfirefox.com/?q=affiliates&amp;id=176003&amp;t=215"><img alt="Firefox 2" title="Firefox 2" src="http://sfx-images.mozilla.org/affiliates/Buttons/firefox2/firefox-spread-btn-4.png" border="0"></a>
</TD></TR>
 </TABLE></div>
It just stays at the left.
BTW -- I'm testing using Konqueror and Firefox. It works in IE, but I don't really care about that :biggrin:
 
Last edited by a moderator:

DarkDragonLord

New Member
Messages
782
Reaction score
0
Points
0
Put the table inside these
HTML:
<div id="Aligner">

</div>
The id can be anything.

Then, in the .css file
add as following:
HTML:
#Aligner {
width: 100%;
height: 100%;
text-align:right;
}

This will work.


Or, if you dont use a external css file, add the following:
HTML:
<div id="Aligner" style="width:100%; height:100%; text-align: right;">


</div>



Enclose the table inside this code.

<div align="right"></div>

Its so simple.

If you need further clarification, post the jist of the intended code which you want to right align.

Thank you,

All the best
Its simple but just work in IE because it is a non-standard browser.

In Web Standards, DIV does NOT have an 'align' atribute, not 'valign' as well. Those are only table's tr and td atributes.
In standard, aligning something in DIV is text-align.. If you want a div to use valign as well, you need to add in css file/style tag
HTML:
display:table-cell; vertical-align:top;
 
Last edited:

Hazirak

New Member
Messages
197
Reaction score
0
Points
0
In a browser like IE6, you can just use text-align and it will align the entire page. However, this is not the case in a standards-compliant browser - it will align only the text.

A way to get everything to align in a standards-compliant browser would be to use the "float" attribute in CSS.

Example of both the above.

HTML:
<div style="float:right">
    This text is floated to the right.
    <table border="1" cellpadding="0" cellspacing="0">
        <tr>
            <td>
                This table is floated to the right.
            </td>
        </tr>
    </table>
</div>
Also, you could include that externally in a stylesheet:
HTML:
<div class="aligner">
    This text is floated to the right.
    <table border="1" cellpadding="0" cellspacing="0">
        <tr>
            <td>
                This table is floated to the right.
            </td>
        </tr>
    </table>
</div>
HTML:
.aligner {
float:right;
}
It would all work the same.

There's just one thing you have to be careful about when using the "float" attribute - everything after the floated element will wrap around it. So if I were to insert an <hr /> tag after the floated div tag in that example page, instead of appearing on a new line, a horizontal line would appear to the left of the floated text. If you don't want this effect, a simple solution would be to use "clear:right;" in the element you do not want to wrap.
 
Last edited:
F

Fahad

Guest
@DarkDragonLord:
Doesn't work - tested Konqueror and Firefox.
@Hazirak:
Works - only problem is that you have to scroll all the way right to see it - Firefox, Konqueror, and annoyingly, IE

The link is in my sig - you'll see what I mean
 
Last edited by a moderator:

Hazirak

New Member
Messages
197
Reaction score
0
Points
0
HTML:
<div style="float: right; width:150px;">
Replace your div tag with that (or just throw the width part in), should do the trick.
 
F

Fahad

Guest
Hazirak was first to post a working solution.
I've already PMed sunils to transfer his credits to Hazirak.
 
F

Fahad

Guest
Great, thanks again.
Post when you receive the credits and I'll close this thread
 

Hazirak

New Member
Messages
197
Reaction score
0
Points
0
Seems like I did, but I'm honestly not hugely concerned with the credits, so feel free to just close this. If I get them, I get them. If not, oh well, life goes on as per normal.
 
F

Fahad

Guest
sunils promised transfer on Wednesday. I'll just rep you, thats 25 creds.
 
Top