i’m trying to make a menu, i want my menu looks like centered to left and right side of page in all resolutions. eg;
800 width
----------------------------------------
| menu item1 menu item2 menu item3 |
| |
----------------------------------------
1920 width
------------------------------------------------
| menu item1 menu item2 menu item3 |
| |
------------------------------------------------
i’ve write a jquery function that calculates a new margin value for screen width and changes margin for every menu item. That works good. But i want to learn is it possible to do this only with css?
I also tried margin-left:5% but when screen has low width like 800, my menu items dont fit to div and some items go down.
well, the problem with the percentages is that they become very hard to work with when mixed with constants. You could probably make the items fit into the div by defining a % value for their font-sizes/paddings/line-heights as well.
On the other hand, if you only have 3 items in the menu, it would be easier to use float:left/right on item 1 and 3 and only change their margins based on the screen width. Ofcourse this probably wouldn’t work on menus with more items.