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:
.blade//
Veteran Member
*****

Avatar

Posts: 2856
Reputation: 39
35 / Male / –
Joined: Jan 2004
O.P. Dodgy  Center an object in HTML while having it at location '0' from the top...
OK, here's the deal - In HTML, I need to center rather a table or an iframe, but also have it at location '0' from the top, anyone have any ideas?
[Image: A%20Pointy%20Rock.jpg]
09-10-2004 04:34 PM
Profile PM Web Find Quote Report
fluffy_lobster
Veteran Member
*****

Avatar
Posts: -2

Posts: 1391
Reputation: 23
36 / Male / Flag
Joined: Nov 2002
RE: Center an object in HTML while having it at location '0' from the top...
Center it horizontally or vertically?
09-10-2004 06:53 PM
Profile E-Mail PM Web Find Quote Report
.blade//
Veteran Member
*****

Avatar

Posts: 2856
Reputation: 39
35 / Male / –
Joined: Jan 2004
O.P. RE: Center an object in HTML while having it at location '0' from the top...
I need it to be at the VERY TOP of the page (no space between the top and the object) but centered from left to right (horizontally)
[Image: A%20Pointy%20Rock.jpg]
09-10-2004 06:59 PM
Profile PM Web Find Quote Report
fluffy_lobster
Veteran Member
*****

Avatar
Posts: -2

Posts: 1391
Reputation: 23
36 / Male / Flag
Joined: Nov 2002
RE: Center an object in HTML while having it at location '0' from the top...
<body topmargin="0"><table align="center">...
09-10-2004 07:07 PM
Profile E-Mail PM Web Find Quote Report
.blade//
Veteran Member
*****

Avatar

Posts: 2856
Reputation: 39
35 / Male / –
Joined: Jan 2004
O.P. RE: Center an object in HTML while having it at location '0' from the top...
Thanks :banana:


btw, ur sig. is wrong - it says I'm using FF 0.8, but I'm using FF 0.9 :refuck:...:P

This post was edited on 09-10-2004 at 07:22 PM by .blade//.
[Image: A%20Pointy%20Rock.jpg]
09-10-2004 07:21 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 fluffy_lobster
<body topmargin="0"><table align="center">...
Ewww!
God's sake.

HTML:
<iframe id="myframewhichiwantcentered" ....></iframe>
CSS:
#myframewhichiwantcentered {
position: absolute;
top: 0px;
width: [framewidth]px;
left: 50%;
margin-left: -[framewidth]px;
}

Don't do it in CSS, then don't do it at all, or perlease keep it XHTML compliant...
or if you can't be bothered to keep the CSS somewhere seperate; do it the lame way:

<iframe style="position: absolute; top: 0px; left: 50%; width: [framewidth]px; margin-left: -[framewidth]px;" .....></iframe>

Btw, Iframes are ghay =)

~lhun
{ -[Image: lhunath.gif]- }
09-10-2004 09:46 PM
Profile E-Mail PM Web Find Quote Report
.blade//
Veteran Member
*****

Avatar

Posts: 2856
Reputation: 39
35 / Male / –
Joined: Jan 2004
O.P. RE: Center an object in HTML while having it at location '0' from the top...
I got it to work with the way fluffy said...
[Image: A%20Pointy%20Rock.jpg]
09-10-2004 09:55 PM
Profile PM Web Find Quote Report
k776
Junior Member
**

Avatar

Posts: 98
Reputation: 3
– / Male / –
Joined: Aug 2004
RE: Center an object in HTML while having it at location '0' from the top...
yeah, but that way isn't going to show the saem on all browsers the way lhunath suggested is better.
[Image: k776.jpg]
09-10-2004 10:06 PM
Profile 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...
The easiest way is to use CSS, and use
code:
vertical-align : top;
align : center;
Those are the only two properties you need, and they also allow for different screen/window sizes.

I beg you, don't use absolute sizing/positioning! It gets messed up when the resolution/window size changes!
[Image: spartaafk.png]
09-10-2004 10:31 PM
Profile PM Web Find Quote Report
fluffy_lobster
Veteran Member
*****

Avatar
Posts: -2

Posts: 1391
Reputation: 23
36 / Male / Flag
Joined: Nov 2002
RE: Center an object in HTML while having it at location '0' from the top...
quote:
Originally posted by lhunath
quote:
Originally posted by fluffy_lobster
<body topmargin="0"><table align="center">...
Ewww!
God's sake.

HTML:
<iframe id="myframewhichiwantcentered" ....></iframe>
CSS:
#myframewhichiwantcentered {
position: absolute;
top: 0px;
width: [framewidth]px;
left: 50%;
margin-left: -[framewidth]px;
}

Don't do it in CSS, then don't do it at all, or perlease keep it XHTML compliant...
or if you can't be bothered to keep the CSS somewhere seperate; do it the lame way:

<iframe style="position: absolute; top: 0px; left: 50%; width: [framewidth]px; margin-left: -[framewidth]px;" .....></iframe>

Btw, Iframes are ghay =)

~lhun
You're right - I wasn't aware the topmargin attribute was no longer valid.  However blade was asking for an HTML solution, so I hardly see preaching that mess of a css hack a tidy alternative.  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;">

For the horizontal centering, either raceprouk's align: center; style or the html attribute align="center" are valid and intercompatible.

By the way, racepro, the vertical-align: top; is obsolete because that's the default for members of the <body> element. The issue with top aligning it was that there is a default top margin of something like 10px
09-11-2004 11:21 AM
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