problem horizontaly centering a menu on webpage

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeff

    problem horizontaly centering a menu on webpage

    hi

    asp.net 2.0

    I wan thte menu to be horizontally centered on the webpage, but I want the
    submenuitems to left aligned.
    So I created a table cell with HorizontalAlign set to Center. With this
    option set the menu was horizontaly centered as I wanted, except that also
    submenuitems was centered too (not what I wanted). So then I tryed to add a
    extra div around the menu (<div style="text-align:left; margin-left:auto;
    margin-right:auto;">). But that didn't help either...

    any suggestions?

    Here is my markup:
    <asp:TableCel l BackColor="Blue Violet" ColumnSpan="2"
    HorizontalAlign ="Center">
    <asp:LoginVie w ID="LoginView2 " runat="server">
    <AnonymousTempl ate></AnonymousTempla te>
    <RoleGroups>
    <asp:RoleGrou p Roles="Administ rator">
    <ContentTemplat e>
    <div style="text-align:left;
    margin-left:auto; margin-right:auto;">
    <asp:Menu ID="Menu1" runat="server"
    SkinID="menu"
    CssClass="menu"
    DataSourceID="s mdsAdministrato r"
    StaticDisplayLe vels="2"
    Orientation="Ho rizontal">
    </asp:Menu></div>

    skin:<asp:menu runat="server"
    SkinId="menu"
    BackColor="#f0f 0f0"
    ForeColor="#6B0 808"
    StaticMenuItemS tyle-HorizontalPaddi ng="5px"
    DynamicHoverSty le-BackColor="#6B0 808"
    DynamicHoverSty le-ForeColor="#FFF FFF"
    StaticSubMenuIn dent="10px"
    DynamicMenuItem Style-HorizontalPaddi ng="5px"></asp:menu>


  • Cowboy \(Gregory A. Beamer\)

    #2
    Re: problem horizontaly centering a menu on webpage

    I find it easiest to use the CSS Friendly adapters
    (http://www.codeplex.com/cssfriendly) and use CSS to set up the different
    elements. You have much more control.

    You can use CSS with the standard controls, as well, but it is not as easy.

    --
    Gregory A. Beamer
    MVP, MCP: +I, SE, SD, DBA

    Subscribe to my blog


    or just read it:


    *************** *************** **************
    | Think outside the box! |
    *************** *************** **************
    "Jeff" <it_consultant1 @hotmail.com.NO SPAMwrote in message
    news:OrtBlqjIJH A.1060@TK2MSFTN GP03.phx.gbl...
    hi
    >
    asp.net 2.0
    >
    I wan thte menu to be horizontally centered on the webpage, but I want the
    submenuitems to left aligned.
    So I created a table cell with HorizontalAlign set to Center. With this
    option set the menu was horizontaly centered as I wanted, except that also
    submenuitems was centered too (not what I wanted). So then I tryed to add
    a extra div around the menu (<div style="text-align:left;
    margin-left:auto; margin-right:auto;">). But that didn't help either...
    >
    any suggestions?
    >
    Here is my markup:
    <asp:TableCel l BackColor="Blue Violet" ColumnSpan="2"
    HorizontalAlign ="Center">
    <asp:LoginVie w ID="LoginView2 " runat="server">
    <AnonymousTempl ate></AnonymousTempla te>
    <RoleGroups>
    <asp:RoleGrou p Roles="Administ rator">
    <ContentTemplat e>
    <div style="text-align:left;
    margin-left:auto; margin-right:auto;">
    <asp:Menu ID="Menu1" runat="server"
    SkinID="menu"
    CssClass="menu"
    DataSourceID="s mdsAdministrato r"
    StaticDisplayLe vels="2"
    Orientation="Ho rizontal">
    </asp:Menu></div>
    >
    skin:<asp:menu runat="server"
    SkinId="menu"
    BackColor="#f0f 0f0"
    ForeColor="#6B0 808"
    StaticMenuItemS tyle-HorizontalPaddi ng="5px"
    DynamicHoverSty le-BackColor="#6B0 808"
    DynamicHoverSty le-ForeColor="#FFF FFF"
    StaticSubMenuIn dent="10px"
    DynamicMenuItem Style-HorizontalPaddi ng="5px"></asp:menu>
    >

    Comment

    • =?Utf-8?B?YnJ1Y2UgYmFya2Vy?=

      #3
      RE: problem horizontaly centering a menu on webpage

      when you set the alignment of a div, you are setting the aligmnent of its
      content, not the div. you probably wanted to center the div, and leave its
      content left aligned. to center a div you set its margins:

      <div style="margin-left:auto;margi n-right:auto;">

      -- bruce (sqlwork.com)


      "Jeff" wrote:
      hi
      >
      asp.net 2.0
      >
      I wan thte menu to be horizontally centered on the webpage, but I want the
      submenuitems to left aligned.
      So I created a table cell with HorizontalAlign set to Center. With this
      option set the menu was horizontaly centered as I wanted, except that also
      submenuitems was centered too (not what I wanted). So then I tryed to add a
      extra div around the menu (<div style="text-align:left; margin-left:auto;
      margin-right:auto;">). But that didn't help either...
      >
      any suggestions?
      >
      Here is my markup:
      <asp:TableCel l BackColor="Blue Violet" ColumnSpan="2"
      HorizontalAlign ="Center">
      <asp:LoginVie w ID="LoginView2 " runat="server">
      <AnonymousTempl ate></AnonymousTempla te>
      <RoleGroups>
      <asp:RoleGrou p Roles="Administ rator">
      <ContentTemplat e>
      <div style="text-align:left;
      margin-left:auto; margin-right:auto;">
      <asp:Menu ID="Menu1" runat="server"
      SkinID="menu"
      CssClass="menu"
      DataSourceID="s mdsAdministrato r"
      StaticDisplayLe vels="2"
      Orientation="Ho rizontal">
      </asp:Menu></div>
      >
      skin:<asp:menu runat="server"
      SkinId="menu"
      BackColor="#f0f 0f0"
      ForeColor="#6B0 808"
      StaticMenuItemS tyle-HorizontalPaddi ng="5px"
      DynamicHoverSty le-BackColor="#6B0 808"
      DynamicHoverSty le-ForeColor="#FFF FFF"
      StaticSubMenuIn dent="10px"
      DynamicMenuItem Style-HorizontalPaddi ng="5px"></asp:menu>
      >
      >
      >

      Comment

      Working...