Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 26th, 2010, 05:57 PM
Authorized User
 
Join Date: Jun 2009
Posts: 70
Thanks: 18
Thanked 1 Time in 1 Post
Default Page 250 static over styles

Referring closely to the book, I have been working up a site with a vertical menu - and text-only buttons - no images or background color for the static menu.

Master page:

Code:
<asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource1" StaticEnableDefaultPopOutImage="False">
                <StaticMenuItemStyle CssClass="StaticMenuItemStyle" />
                <StaticHoverStyle CssClass="StaticHoverStyle" />
            </asp:Menu>
                    <asp:SiteMapDataSource ID="SiteMapDataSource1" ShowStartingNode="False" runat="server" />
CSS
Code:
.StaticHoverStyle
{
    /* Defines the look of active and hover menu items */
    color:Blue;
    background-color:#3a3a3a;
}
There is a change to the expected background color when hovering. BUT the color of the font does NOT change. Any suggestions as to why not?
 
Old March 26th, 2010, 06:10 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Maybe some other rule is more specific? Consider this:

#MainMenu a
{
color: red;
}

.StaticHoverStyle{
color: green;
}

In this case, the rule from #MainMenu a is said to be more specific as it contains an ID and a tag selector (101), instead of just a class selector (10). This means the former rule wins.

Possible ways to fix:

1. Make the other rule less specific

2. Make the hover rule more specific (maybe use .MainMenu .StaticHoverStyle, provided you assigned a class name of MainMenu to the Menu control)

3. Add: !important to the property value:

color: green !important;

You can read more about specificity here:

http://htmldog.com/guides/cssadvanced/specificity/

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
kiwibrit (March 26th, 2010)
 
Old March 26th, 2010, 08:03 PM
Authorized User
 
Join Date: Jun 2009
Posts: 70
Thanks: 18
Thanked 1 Time in 1 Post
Default

Thanks, Imar. Following on from your post this has done the trick:

Code:
<asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource1" StaticEnableDefaultPopOutImage="False" CssClass="MainMenu">
              <StaticSelectedStyle CssClass="StaticSelectedStyle" />
            </asp:Menu>
with CSS
Code:
.MainMenu a, .MainMenu a:visited
{
color: red;
}
        
.MainMenu a:hover
{
color:green;
 background-color:#3a3a3a;
}    

.StaticSelectedStyle{
color: Blue !important;
background-color: Fuchsia;
}
Interesting HTML dog article.
 
Old March 27th, 2010, 04:35 AM
Authorized User
 
Join Date: Jun 2009
Posts: 70
Thanks: 18
Thanked 1 Time in 1 Post
Default

For those who may have come across this is a search, in the end, for the effect I actually wanted, this did for me:
Code:
.MainMenu 
{
margin:5px 5px;
}
        
 .StaticMenuItemStyle, .StaticMenuItemStyle a, .StaticMenuItemStyle a:visited
 {
   color:White;
   padding:4px 4px;
 }      
 
.StaticHoverStyle
{
    background-color:#AFAFAF;
}

.StaticSelectedStyle
{
    background-color: #404040;
}
Had I wanted a different selected text color, !important after the color property would have been needed.

Last edited by kiwibrit; March 27th, 2010 at 07:37 AM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Static variables in Static Class JoinTTT BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9 4 March 29th, 2009 05:08 PM
Invoking selection.js library file in static page Manoah Javascript 2 September 2nd, 2008 04:05 AM
non-static reports to static html files miamikk ASP.NET 2.0 Basics 0 June 4th, 2007 01:48 PM
ASP.NET - Static Page and Dynamic Page sohrabus ASP.NET 2.0 Professional 2 April 18th, 2007 11:42 PM
Ch. 7 - Policy Form (p. 250) MER78 BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 September 27th, 2004 03:51 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.