I've created a horizontal menu composed of buttons. I need these buttons to resize in width so that together they occupy 100% of the width of the menu container. It should act the same way a TD does inside a TABLE.
As such, here's the code I came up with:
<div id="menubar">
<div id="menu">
<div class="button">
<Button>Button 1</Button>
</div>
<div class="button">
<Button>Button 2</Button>
</div>
<div class="button">
<Button>Button 3</Button>
</div>
<div class="button">
<Button>Button 4</Button>
</div>
</div>
</div>
and my CSS:
#menubar {
width: 100%;
height: 100%;
display: table;
table-layout: fixed;
}
#menu {
display: table-row;
}
#menu .button {
position: relative;
display: table-cell;
}
#menu .button Button {
position: absolute;
right: 0px;
bottom: 0px;
top: 0px;
left: 0px;
}
This works perfectly in every browser except Mozilla. Mozilla doesn't seem to respect the relative position of the button class and, as such, the Buttons all get positioned absolutely one of top of each other (instead of absolutely inside the DIV with class "button").
After some further research, it seems this is a known issue with Mozilla not respective position "relative" when display is set to "table-cell".
Does anyone know a work around to achieve what I'm looking to do?
Note: The menu is dynamic so I don't know how many buttons there will be so I can't provide percentage widths for each button.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…