/    Sign up×
Community /Pin to ProfileBookmark

table aligning with css

Is it possible to align a table, or anyother object for that matter, vertically in the middle? I’m going to make a page that’s not going to be more than 800×600. So, i want to vertically align my table with all the content in in the center of the window, even if the resoltuion is changed to lets say 1024×768. Is this possible with css.
Thanks

to post a comment
CSS

4 Comments(s)

Copy linkTweet thisAlerts:
@Zach_ElfersDec 09.2002 — position:absolute;left:50%;top:50%;
Copy linkTweet thisAlerts:
@StefanDec 09.2002 — [i]Originally posted by minulescu [/i]

[B]Is it possible to align a table, or anyother object for that matter, vertically in the middle? [/QUOTE]




Only if you know it's exact height & width, (unless it's a background image).



eg

position:absolute;left:50%;top:50%; width:200px; height:300px; margin:-150px 0 0 -100px;





BTW, you shouldn't be using <table> for creating general layout in the first place.
Copy linkTweet thisAlerts:
@minulescuauthorDec 09.2002 — I know i shouldnt be using table for alignment, but i dunno too much about css, so I'm gonna "abuse" tables, like U usually say Stefan ? . I know i shouldnt but hey, what can I do. I'm gonna use what I can and know how to use. I have one question tho. If u set the margin, like you did above, is that only for the item/object specified?? or does it change my whole page to that margin?

Thanks
Copy linkTweet thisAlerts:
@StefanDec 09.2002 — [i]Originally posted by minulescu [/i]

[B]. I have one question tho. If u set the margin, like you did above, is that only for the item/object specified??[/B][/QUOTE]


Yes, you want to specify it for the specific object you want to center.
×

Success!

Help @minulescu spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...