/    Sign up×
Community /Pin to ProfileBookmark

Center Aligning Div

Alright, sounds easy. . . Well, I’m having some problems. Here’s the code:

[CODE]/* Navigation */
#nav-span {
vertical-align:top;
font-family: Comic Sans MS, cursive;
border:1px;
border:solid;
border-color:#CCC;
text-align:center;
background-color:#00F;
font-weight:445;
width:600px;
}
.nav {
color:#FFF;
}[/CODE]

[code=html]<head>
<link href=”styles/main.css” rel=”stylesheet” type=”text/css” />
</head>
<body>
<div id=”nav-span”>
<a href=”./home.php” class=”nav”>Home</a>&nbsp;|
<a href=”./pages/people.php” class=”nav”>About Us</a>&nbsp;|
<a href=”./pages/youtube.php” class=”nav”>Youtube Profile</a>&nbsp;|
<a href=”./pages/about.php” class=”nav”>About STA</a>&nbsp;|
<a href=”./pages/videos.php” class=”nav”>Videos</a>
</div>
</body>[/code]

to post a comment
CSS

2 Comments(s)

Copy linkTweet thisAlerts:
@skywalker2208Nov 14.2008 — I think you need margin: 0px auto;
Copy linkTweet thisAlerts:
@OctoberWindNov 14.2008 — If you add {margin: 0 auto;} to your #nav-span, that will center it within its parent tags.

I'd also like to take a look at your use of [b]border[/b]

[b]border[/b] is the shorthand tag, and needs 1-3 of the styles defined by it.

width (size)

style (type: solid, dashed, double)

color (well, color.)

The way you have it it your css, boder: 1px is overwritten by border: solid. border-color: #ccc is fine.

since all 4 border are going to be the same, what I would do it use this instead.

[code=html]
border: solid 1px #ccc;
[/code]


I've never found that order makes a difference; whether it's [i]solid 1px #ccc[/i] or [i]1px solid #ccc[/i].

By default, Firefox displays [b]border: solid[/b] as (from what i could figure) 4px. which is a lot different than 1px.

if you did have to separate each border and its properties, do so like this:
[code=html]
border-top-width: 1px;
border-top-style: solid;
border-top-color: #ccc;
boder-right-width: 1px;
...
[/code]

and so on, for border-right, border-bottom, and border-left.
×

Success!

Help @njven 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.6,
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,
)...