Solved

duplicate background images in asp.net menuitem

Posted on 2006-10-19
5
1,635 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …

772 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now