add background images to menu control

Last post 11-12-2008 8:20 AM by novicehere. 3 replies.

Sort Posts:

  • add background images to menu control

    11-08-2008, 4:37 AM
    • Member
      264 point Member
    • anagha
    • Member since 03-11-2008, 9:43 AM
    • Mumbai, India
    • Posts 105

    how to apply background image for menu control using css ?

    can anybody help me out with this??

    i don't want to use CSS friendly control adapters

    Thanks in advance... 

     

  • Re: add background images to menu control

    11-08-2008, 9:44 PM
    Answer
    • Contributor
      4,650 point Contributor
    • novicehere
    • Member since 01-28-2008, 2:21 PM
    • New Hampshire, US
    • Posts 852

    Hello There,

    here is small sample. i hope it gives an idea,

    <div id="MyMenu">

    <asp:Menu ID="Menu" runat="server" Orientation="Horizontal" >

    <Items>

    <asp:MenuItem Text="Home" ToolTip="Home" >

    <asp:MenuItem Text="Cookies" ToolTip="Cookies">

    <asp:MenuItem Text="Chocolate Chip Cookies" NavigateUrl="~/ccc.aspx" ToolTip="Chocolate Chip Cookies" />

    <asp:MenuItem Text="OatMeal Rasin Cookies" NavigateUrl="~/ccc.aspx" ToolTip="OatMeal Rasin Cookies" />

    <asp:MenuItem Text="No Bake Cookies" NavigateUrl="~/ccc.aspx" ToolTip="No Bake Cookies" /></asp:MenuItem>

     

    <asp:MenuItem Text="Chocolates" ToolTip="Chocolates">

    <asp:MenuItem Text="Hard Candy" NavigateUrl="~/ccc.aspx" ToolTip="Hard Candy" />

    <asp:MenuItem Text="Soft Candy" NavigateUrl="~/ccc.aspx" ToolTip="Soft Candy" />

    <asp:MenuItem Text="Sugar Free Candy" NavigateUrl="~/ccc.aspx" ToolTip="Sugar Free Candy" />

    </asp:MenuItem>

    <asp:MenuItem Text="Ice Cream" ToolTip="Ice Cream">

    <asp:MenuItem Text="Hard Serve" NavigateUrl="~/ccc.aspx" ToolTip="Hard Serve" />

    <asp:MenuItem Text="Soft Serve" NavigateUrl="~/ccc.aspx" ToolTip="Soft Serve" />

    </asp:MenuItem> </asp:MenuItem>

    </Items>

    <StaticMenuItemStyle CssClass="Item" />

    <StaticSelectedStyle CssClass="SelectedItem" />

    <StaticHoverStyle CssClass="HoverItem" />

    <DynamicMenuItemStyle CssClass="Item" />

    <DynamicSelectedStyle CssClass="SelectedItem" />

    <DynamicHoverStyle CssClass="HoverItem" />

    </asp:Menu>

    now the CSS involved

    <style type="text/css" runat="server"> <!--

    #MyMenu{

    /* Lets leave it blank */

    }

    #MyMenu .Item

    {

    /* CSS class for non-selected Menu Item */

    background-image: url(../images/coffeecold.jpg);

    background-repeat: no-repeat;

    }

    #MyMenu .SelectedItem, #MyMenu .HoverItem

    {

    /* CSS class for hovering and selected Menu Item

    i am using same image for hover and selected item,

    we can use different ones also */

    background-image: url(../images/coffeehot.jpg); background-repeat: no-repeat;

    }

    /* CSS classes for standard Links for #MyMenu  DIV */

    #MyMenu a, #MyMenu a:visited

    {

    background-color: transparent ! important; /* the reason we use !important is to override the images we just set in

    item, selected items and hover for the "anchor class like a:visted, a:hover etc" */

    display: block;

    }

    #MyMenu a:hover, #MyMenu a:active, #MyMenu a:focus

    {

    background-color: transparent ! important; /* the reason we use !important is to override the images we just set in

    item, selected items and hover "anchor class like a:visted, a:hover etc" */

    display: block;

    }

    -->

    </style>

    Thanks

    Keyboard not found. Please Press < F1 > to RESUME

    Please Remember to Mark as Answer for the post(s) that help you.....so it can help others......Thanks
  • Re: add background images to menu control

    11-12-2008, 3:32 AM
    • Member
      264 point Member
    • anagha
    • Member since 03-11-2008, 9:43 AM
    • Mumbai, India
    • Posts 105

    I tried this but not working

    i don't know why.

  • Re: add background images to menu control

    11-12-2008, 8:20 AM
    • Contributor
      4,650 point Contributor
    • novicehere
    • Member since 01-28-2008, 2:21 PM
    • New Hampshire, US
    • Posts 852

    Hello There,

    Please post your code

    Thanks

    Keyboard not found. Please Press < F1 > to RESUME

    Please Remember to Mark as Answer for the post(s) that help you.....so it can help others......Thanks
Page 1 of 1 (4 items)