Please consider the following: http://jsfiddle.net/CASM6/9/
I have two rows of tabs. there are two tabs in the first row and 3 tabs in the second row. I want all these tabs to neatly fall inside one rectangle, with the outer borders to match perfectly. If there were no borders, this would be easy. The width for the upper tabs would be 50%, and the width for lower tabs would be 33.333333%. But the lower tabs have borders. And the width of these borders messes things up. How do I achieve the desired result? Thanks!
This is probably not what you want to hear, but if you want to mix percentages and px you will have the easiest time by adding an extra wrapper element. That is, if you want to be accurate.
I wrapped your
licontent in adiv, and set the border on thedivinstead.Demo: http://jsfiddle.net/CASM6/13/
50emhttp://jsfiddle.net/CASM6/21/3emcontainer: http://jsfiddle.net/CASM6/20/Besides that
0.1%leftover from splitting the container into imperfect thirds, the layout is pixel perfect in each example. You can compensate for that by setting abackground-coloron the container that matches the border.You can fiddle around with fractions of ems and percentages all day, but you can never get them perfect because they are relative widths, unlike
px. This might work if you know the exact pixel width of your container, but then if that’s the case you could have just usedpxunites to measure everything. This method ensures accuracy at any width.