css scripters :D
•
14 Jan 2010, 17:36
•
Journals
hello crossfire friends, long time no speak :]
anyways ill get to the point, im designing a website by using css :o
i want to center my navigation bar, but I don't know the coding for it :/
so if anyone can give me a hand, ill give them a code to demonoid :p
anyways ill get to the point, im designing a website by using css :o
i want to center my navigation bar, but I don't know the coding for it :/
so if anyone can give me a hand, ill give them a code to demonoid :p
maak team voor lan
lets paly later!!
So make the navbar like you normally would in html using tables and shit or whatever you want to (you can actually make such stuff using nothing but css but I suppose you'll make the basic layout with html)
then you put the whole navbar structure inside <div> tags like this:
and put this in your stylesheet file
That sets top and bottom margins to 0 and left and right margins to auto. also centers text.
There's a catch though, this makes the box size dependant on content. If you want to have a fixed size, use this instead:
Becos this makes it so that there's always 20% space as a margin to your navbox no matter how little or much content you have there. If the content is too much to fit into the box, it will go into a new line stretching the box down.
Fuck if I know if they work, I've done quite a bit of coding though (In this work practice shit i was at a local advertising agency place and I coded some web layouts to them using various methods including using pretty much nothing but css and div tags XD)
E: It's also possible to center the tables directly in html - but that's deprecated nowadays and therefore not valid and might stop working in future revisions of the language.
E2: if you wait a moment I'll fix this old layout of mine (as in make the code a little more valid) and you can use it as an example.
margin:0 auto;
margin 0px auto;
margin:0px auto 0px auto;
all the above are the same, remember its top,left,bottom,right - so what we are doing here is setting left and right to auto and it will center within its current container
PS container is another word for something like a <div>
Your doing the right thing - dont use tables to lay a website out. Once you get used to css its easy, gives you more creative flexibility, allows for easy theme changes, faster for the browser, and it is XHTML strict if you do it right - that means it will looks right on anything including small devices.
The post above is correct except you don't need
text-align:center;
That's for text - the guy got confused because there is an old trick to centering <div> in ie5 browser using that, no one uses ie5 so don't worry about it.
And also don't use margins to set the width like he said, use width:100% or width:66px etc
hahahah, that's a big bs, u obviously don't know how many ppl actually use it, fact that gamers don't use it doesn't mean nobody does!
i put tricks in to make it work on old browsers because im a perfectionist, but making your code practices wrong so it works on very old ones because they got it wrong is not that great an idea imo. Actually I believe the only one you need to do this for is if you are centering the main web container anyway and then you do:
body{
text-align:center;
}
But I dunno why people would use ie5 tbh, its so insecure and displays wrongly, even ie6 is fucked - but I take your word for it.
Also this is for a gaming website!
cheers
http://burneddi.pingviini.info/filut/leiskareviivi
Preview
Soyeah it uses tables for basic structure but they don't have any properties in them - I know it's nowadays recommended to use nothing but CSS but it's quite complex if you're not too experienced with all this stuff. Besides, tables work fine..
It's even valid, after I removed some silly errors!
http://burneddi.pingviini.info/filut/leiskareviivi/images/keskiosa.gif
http://burneddi.pingviini.info/filut/leiskareviivi/images/navi.gif
You sir made my day! : DDDDDDDDDDDDDDDDDDDDDDDDDDDD
Thank's for notifying though, i'll remove them. It actually uses no images at all in it's current state - except for the favicon.
Back then I was young, foolish and inexperienced though.
have a look at how clean the code is!
http://www.hiphopmonster.com/Div_3Column/index.html
The lad is obviously creating a website for small community, and isn't too experienced with web developing. While I agree with you in that creating web pages that work on practically everything you can think of ("Working" is a relative thing though - It's really hard to read that page of yours on a small resolution when there's like 1 letter per line in the main box, and because the boxes stretch all the way to the borders of your screen it looks silly on large widescreens, too. That's easily fixed though), it's quite silly to urge their importance to someone who has just started with all this stuff.
The bad thing about table layouts is that they don't scale unless you use some javascript or other hacks, which is widely considered bad.. Although I recall having to use javascript in a CSS tableish layout to stop a copyright box from stretching to the right edge of your screen (and there was no other way to stop it from doing that) :-)
E: Pardon me opening poster, looking at this website of yours, damn, it's nicely coded :P! And I see your problem too, I'll see if I can't find a fix. I'm just an amateur, after all.
oh and dump xhtml, it has no future. apart from the fact that its still being served as html :x
A webmaster thinks he is cool, because he produced a website in xhtml 1.0. What he doesnt know is that his website is served as text/html and not as application/xhtml+xml anyways. This way the browser receives a badly written html 4.01 (since the page is correct with xhtml 1.0 standard; mainly its about the trailing tags, but not only). The reason why browsers display the page properly nonetheless, is because they ignore the faults of the code, use loose rules while processing data, etc.
Having two languages: xhtml and html, w3c had to choose one standard from these two. Some time ago w3c decided to support html 5.
http://www.w3.org/News/2009#entry-6601 this one and scroll up a bit, there is another news confirming the draft group working on xhtml 2.0 wont be renewed. this is to accelerate progress of html 5.
EDIT: http://www.w3.org/2009/06/xhtml-faq.html this one is worth reading too.