i cant center my stuff using css

Status
Not open for further replies.

habbz

Custom Title bitchssssssss
Nov 12, 2010
227
1
i cant center my navi bar at the top left using css
You must be registered for see images attach

can some one tell me how to?
im just starting to learn css

my failure of css:
Code:
<html>
<head>
<style type="text/css">
.center
{
text-align:center;
}
body
{
background-image:url('gradient2.png');
background-repeat:repeat-x;
}
ul
{
list-style-type:none;
margin-left: auto;
margin-right: auto;
padding:0;
overflow:hidden;
}
li
{
float:left;
margin-left: auto;
margin-right: auto;
}
a
{
display:block;
width:60px;
background-color:#dddddd;
}
</style>
</head>

<body>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#news">News</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="#about">About</a></li>
</ul>
<h1 class="center">Hello!</h1>
<p class="center">i like this background!</p> 
</body>
</html>
 

Markshall

Русский Стандарт
Contributor
Dec 18, 2010
2,637
2,389
Don't take offence to this, but you're trying to build a website and you can't even follow 2 simple instructions, how the fuck is this site going to work out?

Put this in your CSS
Code:
.center { margin: 0 auto; }

Put this in your HTML:
Code:
<div class="center">nav links here.</div>
 

habbz

Custom Title bitchssssssss
Nov 12, 2010
227
1
Dude im seriously doing that look:
Code:
<html>
<head>
<style type="text/css">
.center
{
text-align:center;
margin: 0 auto;
}
body
{
background-image:url('gradient2.png');
background-repeat:repeat-x;
}
ul
{
list-style-type:none;
margin-left: auto;
margin-right: auto;
padding:0;
overflow:hidden;
}
li
{
float:left;
margin-left: auto;
margin-right: auto;
}
a
{
display:block;
width:60px;
background-color:#dddddd;
}
</style>
</head>

<body>
<div class="center">
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#news">News</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="#about">About</a></li>
</ul></div>
<h1 class="center">Hello!</h1>
<p class="center">i like this background!</p> 
</body>
</html>
 

Markshall

Русский Стандарт
Contributor
Dec 18, 2010
2,637
2,389
If you're using IE, switch to Chrome or FireFox, cos i've tried:
Code:
margin: 0 auto;
on IE and sometimes it doesn't work.
 

habbz

Custom Title bitchssssssss
Nov 12, 2010
227
1
Well i am using firefox, and it didnt work, can you look at the code and tell me whats wrong? because its not working on firefox

float:left;
would that mess the code up? because if you look thats there
if you could just edit the code and give me a fixed one and tell
me what i did then that would work to :D
 
Status
Not open for further replies.

Users who are viewing this thread

Top