如何更改asp:从sitemap读取项目的菜单的字体颜色

时间:2012-08-27 08:48:00

标签: asp.net css aspmenu

如何更改asp:menu的fontcolor,它从sitemap读取项目?
ccsClass没有使用它!
这是我的代码:

<asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource1"  
StaticDisplayLevels="2" CssClass="MyMenu"  
StaticSubMenuIndent="18px"   
DynamicMenuItemStyle-BackColor="#C0C0BC"  
DynamicHoverStyle-BackColor="#B3B3B3"  
StaticHoverStyle-BackColor="#666666"  
StaticHoverStyle-ForeColor="#d9d9d6"  
StaticMenuItemStyle-VerticalPadding="1px" StaticPopOutImageUrl="~/Images/control_rewind_blue.png" >

这是ccsClass:

.MyMenu{color:White; font-family:Tahoma; font-size:medium;}  

感谢

2 个答案:

答案 0 :(得分:1)

您可以通过forecolor添加颜色,也可以添加样式

 <asp:Menu ID="Menu1" ForeColor="#003399" style="left: 40px; position: relative; top: 6px" runat="server" DataSourceID="SiteMapDataSource1"  
        StaticDisplayLevels="2" CssClass="MyMenu"  
        StaticSubMenuIndent="18px"   
        DynamicMenuItemStyle-BackColor="#C0C0BC"  
        DynamicHoverStyle-BackColor="#B3B3B3"  
        StaticHoverStyle-BackColor="#666666"  
        StaticHoverStyle-ForeColor="#d9d9d6"  
        StaticMenuItemStyle-VerticalPadding="1px" StaticPopOutImageUrl="~/Images/control_rewind_blue.png" >

答案 1 :(得分:0)

asp:Menu上的每个操作定义一个类,如下所示:

<asp:Menu ID="AspMenu" runat="server">

<StaticMenuStyle CssClass="VerticalMenuli" />
<StaticMenuItemStyle CssClass="VerticalMenuItem" />
<StaticHoverStyle CssClass="VerticalMenuHover" /> 
<StaticSelectedStyle CssClass="VerticalMenuSelectedItem" />

<DynamicMenuStyle CssClass="VerticalMenuSubMenu" />     
<DynamicMenuItemStyle CssClass="VerticalMenuSubMenuItem" />
<DynamicHoverStyle CssClass="VerticalSubMenuHover" /> 
<DynamicSelectedStyle CssClass="SubMenuSelected"/> 

现在,您可以在已定义的类中为任何子菜单或链接指定格式。