所以我试图在我的网站上放一个菜单,但是我很难让子菜单项比第一个菜单项有更小的文本。这是我的代码:
<asp:Menu ID="Menu1" runat="server" Orientation="Horizontal">
<LevelMenuItemStyles>
<asp:MenuItemStyle CssClass="subMenuStyle" />
</LevelMenuItemStyles>
<LevelSubMenuStyles>
<asp:SubMenuStyle CssClass="masterBannerMenu" />
</LevelSubMenuStyles>
<Items>
<asp:MenuItem Text="WHERE I'VE BEEN" NavigateUrl="~/whereivebeen.aspx">
<asp:MenuItem Text="UNESCO Sites" NavigateUrl="~/unesco.aspx" />
<asp:MenuItem Text="Places" NavigateUrl="~/BlogPosts.aspx" />
</asp:MenuItem>
</Items>
</asp:Menu>
以下是呈现的HTML:
<a href="#Menu1_SkipLink"><img alt="Skip Navigation Links" src="/TravelJoansBlog/WebResource.axd?d=i8kPrDg0W2gPsNdgiFoKNbdLkjHOBO6T-YtC_Usb-id70m3Q7jX8wpftWKKoZFCuuiThX_JLEnw1KCG7FBKqB3_JiRZTcYRUnLGsCYCvOwo1&t=634970873020000000" width="0" height="0" style="border-width:0px;" /></a><div id="Menu1">
<ul class="level1 masterBannerMenu">
<li><a class="popout level1 subMenuStyle" href="whereivebeen.aspx">WHERE I'VE BEEN</a><ul class="level2">
<li><a class="level2" href="unesco.aspx">UNESCO Sites</a></li><li><a class="level2" href="BlogPosts.aspx">Places</a></li>
</ul></li>
</ul>
这是相关的CSS:
.masterBannerMenu a
{
font-family:"Century Gothic";
font-size: 16pt;
width: auto;
text-align: left;
color: Black;
text-decoration: none;
}
.subMenuStyle a
{
font-family:"Century Gothic";
font-size: 12pt;
width: auto;
text-align: left;
color: Black;
text-decoration: none;
}
仅应用SubMenuStyles元素中的内容。我试过切换两个CSS类,在asp:Menu控件中设置字体大小然后应用CSS样式,我没有运气。再次,我试图让我的子菜单项文本(教科文组织网站和地点)小于第一级菜单(我在哪里)
答案 0 :(得分:0)
您需要更改.NET标记和/或代码隐藏,以使其生成类似于以下内容的HTML:
<a href="#Menu1_SkipLink"><img alt="Skip Navigation Links" src="/TravelJoansBlog/WebResource.axd?d=i8kPrDg0W2gPsNdgiFoKNbdLkjHOBO6T-YtC_Usb-id70m3Q7jX8wpftWKKoZFCuuiThX_JLEnw1KCG7FBKqB3_JiRZTcYRUnLGsCYCvOwo1&t=634970873020000000" width="0" height="0" style="border-width:0px;" /></a>
<div id="Menu1">
<ul class="level1 masterBannerMenu">
<li><a class="popout level1 subMenuStyle" href="whereivebeen.aspx">WHERE I'VE BEEN</a></li>
</ul>
<ul class="level2">
<li><a class="level2" href="unesco.aspx">UNESCO Sites</a></li><li><a class="level2" href="BlogPosts.aspx">Places</a></li>
</ul>
请参阅FIDDLE