Centering asp:menu item's when there are multiple rows of menu items

508 Views Asked by At

you can replicate my problem with this small code snippet.

    <div ID="topcell" runat="server" align="center" style="text-align:center">
   <asp:Menu ID="testmenu" runat="server" Width="300px" Orientation="Horizontal" RenderingMode="List">

    <Items>
    <asp:MenuItem Text="Testing"></asp:MenuItem>
    <asp:MenuItem Text="Testing"></asp:MenuItem>
    <asp:MenuItem Text="Testing"></asp:MenuItem>
    <asp:MenuItem Text="Testing"></asp:MenuItem>
    <asp:MenuItem Text="Testing"></asp:MenuItem>
    <asp:MenuItem Text="Testing"></asp:MenuItem>



    </Items>
   </asp:Menu>
   </div>

Result:

  • Testing-Testing-Testing-Testing-Testing-Testing
  • Testing----------------------------------------

Desired results:

  • Testing-Testing-Testing-Testing-Testing-Testing
  • ------------------Testing----------------------

I have tried all three RenderingModes with no luck! Am I doing something wrong?

1

There are 1 best solutions below

0
Yuriy Galanter On BEST ANSWER

Try adding following CSS to your page:

<style type="text/css" >
   #testmenu ul li {
      display:inline-block;
      float:none !important;
   }
</style>  

It will overwrite inline menu styles and force the unordered list to center.