I found the following snippet of javascript (uses jQuery) that would allow me to centre a menu/nav that is set to float:left. It seems to work in IE and Opera OK. But in FF and Safari, it works sometimes and other times trips out (keep refreshing the page and it will eventually work/fail). In Chrome it doesn't work at all.
I've never owned any apple products, but I have a coworker who has one and he said it's the best phone he's ever had. And he's pretty much had every apple phone around. His biggest like is the light weight.
Recent Achievements
BizSAR earned a badge Reacting Well
AndreaB earned a badge First Post
Huge Trailer earned a badge Week One Done
Classifyskilleducation earned a badge Week One Done
Question
jordan.
I found the following snippet of javascript (uses jQuery) that would allow me to centre a menu/nav that is set to float:left. It seems to work in IE and Opera OK. But in FF and Safari, it works sometimes and other times trips out (keep refreshing the page and it will eventually work/fail). In Chrome it doesn't work at all.
Here is the code:
$(function() { var menu_width = $('#nav').css('float', 'left').width(); $('#nav').css({float : 'none', width : menu_width, margin : '0 auto'}); });I don't know js so I can't figure out what the problem is. If anyone can help it would be much appreciated.
Here is the page running the code:
http://www.islandrobot.com/vanessa/
Cheers,
Jordan
Link to comment
https://www.neowin.net/forum/topic/894492-js-center-a-menu-that-is-floated-left/Share on other sites
15 answers to this question
Recommended Posts