I am currently facing a challenge in creating a simple sub-navigation system for my website. I want to have either 3 or 4 equally spaced DIVs across the top of the content area. Despite being a common requirement, CSS does not offer straightforward solutions for this problem.
1) For example, having 3 Variable-Width, Equally-Spaced DIVs:
[[LEFT] [CENTER] [RIGHT]]
2) Alternatively, with 4 Variable-Width, Equally-Spaced DIVs:
[[LEFT] [LEFT CENTER] [RIGHT CENTER] [RIGHT]]
My workaround for the first issue with 3 DIVs involves floating the left and right DIVs and setting an arbitrary size for the middle DIV while using "margin: 0 auto". This approach is not ideal but provides a rough solution assuming no changes are made to the navigation.
To address the second problem with 4 DIVs, I center a DIV as before, float two DIVs within it, and set arbitrary sizes for alignment:
[[LEFT] [[LEFT CENTER] [RIGHT CENTER]] [RIGHT]]
However, this method becomes complex when language or image modifications are implemented on the site, necessitating re-calculation of alignment values. It merges structure with presentation, making it overly complicated.
Any assistance in simplifying this task would be greatly appreciated.
EDIT 07/20/2012 5:00PM
I attempted a "table-cell" solution using percentages, which worked to some extent. However, I encountered another issue due to each DIV serving as a container for two additional DIVs, displaying icon-label pairs either floated or displayed inline-block.
For reference: http://jsfiddle.net/c3yrm/1/
The final element in the list appears incorrectly aligned.
Your continued help is highly appreciated!
EDIT 07/20/2012 7:16PM
Thanks to the guidance from arttronics, a final solution has been achieved: http://jsfiddle.net/CuQ7r/4/