Results 1 to 17 of 17

Thread: Help center align the menu div

  1. #1

    Thread Starter
    ^:^...ANGEL...^:^ wrack's Avatar
    Join Date
    Mar 2002
    Location
    Melbourne, AUSTRALIA
    Posts
    2,695

    Resolved Help center align the menu div

    Hi,

    I am creating a simple project with ASP.NET 4 menu and I would like to middle align it within whatever container it is sitting. I have tried everything that I can think of with no joy.

    I am allowed to use jQuery but I don't know much about it and not sure if it can be helpful or not.

    Please see the sample project.

    TA
    Attached Files Attached Files
    Last edited by wrack; Apr 23rd, 2011 at 06:43 PM.

  2. #2
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Help middle align the menu

    Will you be keeping the menu like it is now, that is with two level 1 items or adding more top level items?

    Edit:

    I noticed that you are using a cascading style sheet in your project. Have you tried the align method as you would if you were creating a normal html website?
    Last edited by Nightwalker83; Apr 22nd, 2011 at 04:53 AM. Reason: Adding more!
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  3. #3

    Thread Starter
    ^:^...ANGEL...^:^ wrack's Avatar
    Join Date
    Mar 2002
    Location
    Melbourne, AUSTRALIA
    Posts
    2,695

    Re: Help middle align the menu

    Thanks. No there will me more than 2 top level items. This was just an example.

    I have tried everything I can with CSS.

  4. #4
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Help middle align the menu

    Not sure if this would help? I disable the external css when testing so you may have to do the same. Although, you could place the style code in the css file. the external css seems override that of the css that is internal.

    HTML Code:
    <style>
    .MainMenu
    {
        position:relative;
        vertical-align:middle;
        }
    </style>
    "asp.net" Code:
    1. <asp:Menu ID="mnuMain"  class="MainMenu" runat="server" Orientation="Horizontal"  IncludeStyleBlock="False">
    Last edited by Nightwalker83; Apr 22nd, 2011 at 05:21 AM.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  5. #5

    Thread Starter
    ^:^...ANGEL...^:^ wrack's Avatar
    Join Date
    Mar 2002
    Location
    Melbourne, AUSTRALIA
    Posts
    2,695

    Re: Help middle align the menu

    Hey thanks Nightwalker. I tried that but no change! Could I be missing anything?

  6. #6
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Help middle align the menu

    Quote Originally Posted by wrack View Post
    Hey thanks Nightwalker. I tried that but no change! Could I be missing anything?
    Hello,

    When you say there is no change, did you first clear out your browsers cache? Browsers are notorious for keeps references to cached CSS and JS files etc, and as a result, changes that you have made on the server aren't pushed down to the client.

    Try clearing your cache and try again.

    Gary

  7. #7

    Thread Starter
    ^:^...ANGEL...^:^ wrack's Avatar
    Join Date
    Mar 2002
    Location
    Melbourne, AUSTRALIA
    Posts
    2,695

    Re: Help middle align the menu

    Hi Gary, thanks for the pointer and yes I did clear the browser cache before testing.

    I think Nightwalker fixed the middle alignment as in vertical-align: middle;

    Apologies if the topic title caused confusion. I meant it to align center horizontally.

  8. #8
    Frenzied Member avrail's Avatar
    Join Date
    Mar 2006
    Location
    Egypt, Cairo
    Posts
    1,221

    Re: Help center align the menu div

    i tried your project,
    i think there is something into your css it self,
    i will see more
    in the design mode it is center but not in the run mode :S
    You Don't Have to Rate Me.
    I'm Not a Civilized Man I'm the Civilization it self
    White or Black, Living or Dieing and 0 or 1 that's MY life
    iam an Object in Object Oriented Life
    my blog : http://refateid.blogspot.com/
    twitter :@avrail
    010011000111010101110110001000000100110101111001001000000101000001100011

  9. #9
    Frenzied Member avrail's Avatar
    Join Date
    Mar 2006
    Location
    Egypt, Cairo
    Posts
    1,221

    Re: Help center align the menu div

    ok,
    removing your css class named AdminMasterMenu from your <td>
    and adding align="center" to your menu <td>

    this sent your menu to the center
    but i didn't actually know why text-align:center inside your css class is not working,
    sure there is something else we are missing
    You Don't Have to Rate Me.
    I'm Not a Civilized Man I'm the Civilization it self
    White or Black, Living or Dieing and 0 or 1 that's MY life
    iam an Object in Object Oriented Life
    my blog : http://refateid.blogspot.com/
    twitter :@avrail
    010011000111010101110110001000000100110101111001001000000101000001100011

  10. #10

    Thread Starter
    ^:^...ANGEL...^:^ wrack's Avatar
    Join Date
    Mar 2002
    Location
    Melbourne, AUSTRALIA
    Posts
    2,695

    Re: Help center align the menu div

    Thanks

    BTW this is ASP.NET menu control and looking through FireBug, or IE Developer Tools I noticed it adds a whole heap of inline styles itself! Could they be the culprits?

  11. #11
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Help middle align the menu

    Quote Originally Posted by wrack View Post
    I think Nightwalker fixed the middle alignment as in vertical-align: middle;
    I am confused, this is what I did above:

    HTML Code:
    <&#37;@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
     
    <style>
    .MainMenu
    {
        position:relative;
        vertical-align:middle;
        }
    </style>
    </head>
    <body>
        <form id="form1" runat="server">
        <table style="width: 100%; height: 100%; min-width: 960px; min-height: 704px;" cellpadding="0"
            cellspacing="0">
            <tr class="AdminMasterRow">
                <td class="AdminMasterUser">
                    <asp:Label ID="lblUserPrefix" runat="server" Text="Welcome back,&nbsp;" CssClass="UserPrefix"></asp:Label>
                    <asp:HyperLink ID="hlUser" runat="server" CssClass="UserSuffix">HyperLink</asp:HyperLink>
                </td>
                <td class="AdminMasterMenu">
                    <asp:Menu ID="mnuMain"  class="MainMenu" runat="server" Orientation="Horizontal"  IncludeStyleBlock="False">
                        <Items>
                            <asp:MenuItem Text="Level 1 Item 1" Value="Level 1 Item 1">
                                <asp:MenuItem Text="Level 2 Item 1" Value="Level 2 Item 1"></asp:MenuItem>
                            </asp:MenuItem>
                            <asp:MenuItem Text="Level 1 Item 2" Value="Level 1 Item 2">
                                <asp:MenuItem Text="Level 2 Item 1" Value="Level 2 Item 1">
                                    <asp:MenuItem Text="Level 3 Item 1" Value="Level 3 Item 1"></asp:MenuItem>
                                    <asp:MenuItem Text="Level 3 Item 2" Value="Level 3 Item 2"></asp:MenuItem>
                                </asp:MenuItem>
                            </asp:MenuItem>
                        </Items>
                    </asp:Menu>
                </td>
                <td class="AdminMasterLoginLogout">
                    <asp:LoginStatus ID="lsMain" runat="server" CssClass="LoginLogout" LoginText="LOGIN"
                        LogoutText="LOGOUT" />
                </td>
            </tr>
            <tr>
                <td colspan="3" class="AdminMasterContent">
                </td>
            </tr>
        </table>
        </form>
    </body>
    </html>
    In Fire fox when I run that code it moves the menu horizontally to the center because that is how the div in aligned. Are you saying you want to have the div on the side of the page then the menu appear halfway down?
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  12. #12

    Thread Starter
    ^:^...ANGEL...^:^ wrack's Avatar
    Join Date
    Mar 2002
    Location
    Melbourne, AUSTRALIA
    Posts
    2,695

    Re: Help center align the menu div

    Thanks Nightwalker. Basically I want the menu (whatever ASP.NET renders the menu control to) aligned centrally within the TD.

    I think I know what you are trying to do. But with all the other CSS I have, something gets screwed up! Also it is aligned in the middle when I remove the external css as you mentioned but then I need help with the CSS that may be causing this.

  13. #13
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Help center align the menu div

    Quote Originally Posted by wrack View Post
    I think I know what you are trying to do. But with all the other CSS I have, something gets screwed up! Also it is aligned in the middle when I remove the external css as you mentioned but then I need help with the CSS that may be causing this.
    Try putting:

    Code:
    .MainMenu
    {
        position:relative;
        vertical-align:middle;
        }
    in the css file if you haven't already and see if that makes a difference. If you do that don't forget the asp.net code in post #4.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  14. #14

    Thread Starter
    ^:^...ANGEL...^:^ wrack's Avatar
    Join Date
    Mar 2002
    Location
    Melbourne, AUSTRALIA
    Posts
    2,695

    Re: Help center align the menu div

    Sorry Nightwalker but I tried that with no joy. Can you post your solution please? I want to see the whole thing and find out what am I doing wrong.

    EDIT:

    I have decided to give this up for now as I have higher priority things to do. I will change the whole layout later to make things work better.

    Thanks for all your help.
    Last edited by wrack; Apr 23rd, 2011 at 06:46 PM.

  15. #15
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Help center align the menu div

    Quote Originally Posted by wrack View Post
    Sorry Nightwalker but I tried that with no joy. Can you post your solution please? I want to see the whole thing and find out what am I doing wrong.
    Sorry, I couldn't be of help! Maybe you could draw a picture of what you are trying to do and post it?
    Last edited by Nightwalker83; Apr 24th, 2011 at 06:32 AM. Reason: Fixed spelling!
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  16. #16

    Thread Starter
    ^:^...ANGEL...^:^ wrack's Avatar
    Join Date
    Mar 2002
    Location
    Melbourne, AUSTRALIA
    Posts
    2,695

    Re: Help center align the menu div

    No no, you have been of great help. I think my choice of using table as a basic layout is very bad. I am going to properly redesign the site with DIVs.

  17. #17
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Help center align the menu div

    Quote Originally Posted by wrack View Post
    No no, you have been of great help. I think my choice of using table as a basic layout is very bad. I am going to properly redesign the site with DIVs.
    That would certainly be my recommendation, yes.

    I would start here:

    http://htmldog.com/

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width