/    Sign up×
Community /Pin to ProfileBookmark

begginer: how to keep a page centered at all screen resolutions

i have a simple webpage that I want to keep centered all the time:
the design is optimised to be viewed with resolution of 1280x but i want it to be centered if opened with lower resolutions of 1024 or 800…
i want the horizontal scolbar showing all the time but automatically centered
can anyone offer any help?

to post a comment
CSS

1 Comments(s)

Copy linkTweet thisAlerts:
@WebJoelFeb 28.2007 — i have a simple webpage that I want to keep centered all the time:

the design is optimised to be viewed with resolution of 1280x but i want it to be centered if opened with lower resolutions of 1024 or 800...

i want the horizontal scolbar showing all the time but automatically centered

can anyone offer any help?[/QUOTE]

A horizontal scrollbar showing [I]and[/I] centered? I don't think this is possible... but to center something, give it a WIDTH:foo;, and add MARGIN:0 auto;

To accomodate various wider resolutions, use a percent width:

<div style="[B]WIDTH:90%; MARGIN:0 auto[/B]":>

</div>

The "width:90%;" is easu enough to understand... that is 90% of whatever resolution you/visitor are using (90% of 800px, 90% of 1024px, 90% of 1280px, etc).

MARGIN: 0 auto;" means "zero" margin-top; and "auto-adjust" whatever remains after the 90% has been filled (leaving 5% for the left and another 5% for the right).

-Rather elegant and highly useful arrangement. ?

-Note too that I wrote "0" ("zero") and didn't use "px"? -Shorthand way of writing this. For declaration's value of "zero"-anything, you can omit the suffice type of "px" or "pt" or "em" or "in" or "cm" etc., because 0 = 0 = 0 = 0 = 0, etc...
×

Success!

Help @bbedoyan 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.16,
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,
)...