What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Center an object in HTML while having it at location '0' from the top...

Pages: (2): « First « 1 [ 2 ] Last »
Center an object in HTML while having it at location '0' from the top...
Author: Message:
Banks
Full Member
***

Avatar

Posts: 178
Reputation: 1
36 / Male / –
Joined: Feb 2003
RE: Center an object in HTML while having it at location '0' from the top...
quote:
Originally posted by raceprouk
code:
align : center;


align: center wont work you have to use
code:
margin-left: auto;
margin-right:auto;
09-11-2004 12:34 PM
Profile E-Mail PM Find Quote Report
lhunath
Full Member
***

Avatar
.{ Lord Daisy }.

Posts: 343
39 / Male / –
Joined: May 2004
RE: Center an object in HTML while having it at location '0' from the top...
quote:
Originally posted by raceprouk
The easiest way is to use CSS, and use

code:
vertical-align : top;
align : center;


1. Vertical align isn't even supported in many many browsers, such as, Internet Explorer.
2. Align: center won't work on iframes, but it would on a table containing an Iframe, since what it does is align the content of an object, rather than the object itself.

quote:
Originally posted by fluffy_lobster
All that actually needs to be done is give the body the margin-top: 0px; style, and seeing as it's a lone attribute there's no real reason why not to use inside the tag; <body style="margin-top: 0px;">
Yes, very true, but what I posted is a way of making sure the page remains as dynamic as possible, since I'm using position: absolute. That way, no other content will disturb the flow. Frankly, yes, for his case I assume this sollution would be better (in the case that the object he wants centered itself doesn't have a standard margin/padding - like I assumed as well).

quote:
Originally posted by Banks
code:
margin-left: auto;
margin-right:auto;

Yes! exactly. I use "margin: auto;" though, short-hand. Yet it won't work on absolute positioned objects, like my example, since the auto margin, autos to 0 in that case.

quote:
Originally posted by lhunath
<iframe style="position: absolute; top: 0px; left: 50%; width: [framewidth]px; margin-left: -[framewidth]px;" .....></iframe>
Let me correct myself:
<iframe style="position: absolute; top: 0px; left: 50%; width: [framewidth]px; margin-left: -[framewidth / 2]px;" .....></iframe>

Or like suggested above:
code:
<body style="margin: 0; padding: 0">
<iframe style="margin: auto;" .... ></iframe>
<Iamhtml></Iamhtml>
</body>


This post was edited on 09-11-2004 at 01:45 PM by lhunath.
{ -[Image: lhunath.gif]- }
09-11-2004 01:36 PM
Profile E-Mail PM Web Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
RE: Center an object in HTML while having it at location '0' from the top...
quote:
Originally posted by lhunath
quote:
Originally posted by raceprouk
The easiest way is to use CSS, and use

code:
vertical-align : top;
align : center;


1. Vertical align isn't even supported in many many browsers, such as, Internet Explorer.
2. Align: center won't work on iframes, but it would on a table containing an Iframe, since what it does is align the content of an object, rather than the object itself.
I never specified what element to assign the attributes to, instead leaving that up to whoever uses it. If you use attach those attrs to the <body> element or a <td>, then you'll get the right effect.

Also, I use vertical-align, and it works in both Mozilla and IE.

This post was edited on 09-11-2004 at 02:51 PM by RaceProUK.
[Image: spartaafk.png]
09-11-2004 02:51 PM
Profile PM Web Find Quote Report
lhunath
Full Member
***

Avatar
.{ Lord Daisy }.

Posts: 343
39 / Male / –
Joined: May 2004
RE: Center an object in HTML while having it at location '0' from the top...
quote:
Originally posted by raceprouk
Also, I use vertical-align, and it works in both Mozilla and IE.
I think it works for TD elements only in IE, not sure though. I'd have to check a compliancy table. But it's a fact that the support for it is very buggy & broken as of yet.
{ -[Image: lhunath.gif]- }
09-12-2004 09:33 AM
Profile E-Mail PM Web Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
RE: Center an object in HTML while having it at location '0' from the top...
quote:
Originally posted by lhunath
quote:
Originally posted by raceprouk
Also, I use vertical-align, and it works in both Mozilla and IE.
I think it works for TD elements only in IE, not sure though. I'd have to check a compliancy table. But it's a fact that the support for it is very buggy & broken as of yet.
That won't stop me writing standards-compliant code. It shouldn't stop anyone writing code to the standards, though some of the more experienced web developers favour IE :dodgy:
[Image: spartaafk.png]
09-12-2004 10:40 AM
Profile PM Web Find Quote Report
lhunath
Full Member
***

Avatar
.{ Lord Daisy }.

Posts: 343
39 / Male / –
Joined: May 2004
RE: Center an object in HTML while having it at location '0' from the top...
quote:
Originally posted by raceprouk
That won't stop me writing standards-compliant code. It shouldn't stop anyone writing code to the standards, though some of the more experienced web developers favour IE
Well spoken ;)
{ -[Image: lhunath.gif]- }
09-12-2004 10:58 AM
Profile E-Mail PM Web Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
RE: Center an object in HTML while having it at location '0' from the top...
Thankyou :D
[Image: spartaafk.png]
09-12-2004 11:03 AM
Profile PM Web Find Quote Report
BART SIMPSON416
Junior Member
**

Avatar
[bart416]

Posts: 15
– / Male / –
Joined: Dec 2003
RE: Center an object in HTML while having it at location '0' from the top...
<center></center>
Not more not less.
09-12-2004 11:42 AM
Profile E-Mail PM Web Find Quote Report
lhunath
Full Member
***

Avatar
.{ Lord Daisy }.

Posts: 343
39 / Male / –
Joined: May 2004
RE: Center an object in HTML while having it at location '0' from the top...
quote:
Originally posted by BART_SIMPSON416
<center></center>
Not more not less.
Bluergh. Depricated sickening tags. Urg.
* lhunath gets sick.
* lhunath curses all the people like that who poisoned the beauty of the web to eternities of damnation in the scorching fires of the darkest chambers of the underworld.
{ -[Image: lhunath.gif]- }
09-12-2004 12:02 PM
Profile E-Mail PM Web Find Quote Report
Pages: (2): « First « 1 [ 2 ] Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On