如何使用'id'或'class'属性'标记'自定义菜单项?我需要它来为它应用自定义样式。例如,查看stackoverflow菜单 - 最后一项(问题)有另一种样式(margin-left)。
修改
这是我的.css
div.menu ul
{
list-style: none;
margin: 0px;
padding: 0px;
width: auto;
}
div.menu ul li a, div.menu ul li a:visited
{
background-color: #660000;
border: 1px #4e667d solid;
display: block;
padding: 4px 20px;
margin-left :0px;
margin-right :20px;
text-decoration: none;
white-space: nowrap;
color:White;
}
div.menu ul li a:hover
{
background-color: #cc0000;
color: White;
text-decoration: none;
}
div.menu ul li a:active
{
background-color: #465c71;
color:White;
text-decoration: none;
}
此处代码来自.master
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu"EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal"></asp:Menu>
protected void Page_Load(object sender, EventArgs e)
{
NavigationMenu.Items.Add(new MenuItem("Home",null,null,"~/Default.aspx"));
NavigationMenu.Items.Add(new MenuItem("Home", null, null, "~/Default.aspx"));
NavigationMenu.Items.Add(new MenuItem("Home", null, null, "~/Default.aspx"));
NavigationMenu.Items.Add(new MenuItem("Home", null, null, "~/Default.aspx"));
NavigationMenu.Items.Add(new MenuItem("Home", null, null, "~/Default.aspx"));
}