Solved

duplicate background images in asp.net menuitem

Posted on 2006-10-19
5
1,641 Views
Last Modified: 2007-12-19
I am trying to change the look of the asp.net menu by setting a background image in my stylesheet but in the menu I get duplicate backgrounds like a separate background for the text in that menu item. I have written the following in the stylesheet:

.menuitem
{
      background-image:url(./images/menu_bg.gif);
      width:180px;
      height:25px;
      color:White;
      background-repeat:no-repeat;
}

and the source for the menu looks like this:

<asp:Menu ID="Menu1" runat="server">
                            <LevelMenuItemStyles>
                                <asp:MenuItemStyle BackColor="White" CssClass="menuitem" Font-Underline="False" ItemSpacing="5px" />
                            </LevelMenuItemStyles>
                            <Items>
                                <asp:MenuItem Text="Overview" Value="Overview"></asp:MenuItem>
                                <asp:MenuItem Text="Contacts" Value="Contacts"></asp:MenuItem>
                            </Items>
                        </asp:Menu>

Am I missing something?
0
Comment
Question by:Steverino541
  • 2
5 Comments
 
LVL 30

Expert Comment

by:VirusMinus
ID: 17766212
try

#Menu1
{
     background-image:url(./images/menu_bg.gif);
     width:180px;
     height:25px;
     color:White;
     background-repeat:no-repeat;
}


or better still.. once your page is rendered.. do a view source and paste the HTML here. we can then track down what level / element needs to be styled.
0
 

Author Comment

by:Steverino541
ID: 17766269
Here is how the colde locks in html:

<tr style="height:2px;">
            <td></td>
      </tr><tr style="height:2px;">
            <td></td>
      </tr><tr onmouseover="Menu_HoverStatic(this)" onmouseout="Menu_Unhover(this)" onkeyup="Menu_Key(this)" id="ctl00_Menu1n2">
            <td><table class="menuitem ctl00_Menu1_6" cellpadding="0" cellspacing="0" border="0" width="100%">
                  <tr>
                        <td style="white-space:nowrap;width:100%;"><a class="ctl00_Menu1_1 menuitem ctl00_Menu1_5" href="javascript:__doPostBack('ctl00$Menu1','Contacts')" style="border-style:none;font-size:1em;">Contacts</a></td>
                  </tr>
            </table></td>
      </tr>
0
 
LVL 30

Accepted Solution

by:
VirusMinus earned 250 total points
ID: 17895076
ok there look to be multiple classes being applied to elements here:

<table class="menuitem ctl00_Menu1_6" ... is applying .menuitem AND .ctl00_Menu1_6, track this down in your css

also look at <td style="white-space:nowrap;width:100%;"><a class="ctl00_Menu1_1 menuitem ctl00_Menu1_5"  three different classes are being applied here, including .menuitem which might explain the background for the table and the text.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

CSS3 Custom checkboxes This article shows how to style the checkbox form element using only CSS. Works in: Chrome, FF, Safari, Opera, IE9+ Uses modernizr.js to check for :checked pseudo class, falling back to plain old checkboxes (IE8 and bel…
When writing CSS, there are a few simple rules that will make your life easier.    1. Using ‘* {box-sizing:border-box;}’. Using this will wrap all your elements in a nice little compact box-model that will give you the width you want, like so... …
In this Micro Tutorial users will learn how to embed custom fonts into websites using @font-face in CSS Select a font: Ensure the EULA allows you to use @font-face: Download the font: Get the browser-compatible files you need: Edit your CSS       - Name …
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question