如何在DIV标签中对齐asp:Menu?
我的 CSS 看起来像这样:
#menu
{
width: 1024px;
height: 25px;
margin: 0 auto;
text-align: right;
background-color: Red;
}
我的 asp 页面看起来像这样,(片段):
<asp:Menu ID="mnuMainMenu" runat="server" BackColor="#F7F6F3"
DynamicHorizontalOffset="2" Font-Names="Verdana" Font-Size="Medium"
ForeColor="#7C6F57"
Orientation="Horizontal" StaticSubMenuIndent="10px" Font-Bold="True">
<StaticSelectedStyle BackColor="#5D7B9D" />
<StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
<DynamicHoverStyle BackColor="#7C6F57" ForeColor="White" />
<DynamicMenuStyle BackColor="#F7F6F3" />
<DynamicSelectedStyle BackColor="#5D7B9D" />
<DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
<StaticHoverStyle BackColor="#7C6F57" ForeColor="White" />
<Items>
<asp:MenuItem Text="Projekty" Value="Projekty"></asp:MenuItem>
<asp:MenuItem Text="Licencje" Value="Licencje"></asp:MenuItem>
<asp:MenuItem Text="Kontrahenci" Value="Kontrahenci"></asp:MenuItem>
</Items>
</asp:Menu>
我想让菜单与我的 div 标签的右侧对齐。对齐必须自动完成,如果我添加更多菜单项,菜单应该自行重新对齐。 这在 VS 2008 的分割视图下按预期工作,但在 IE 和 FireFox 中菜单向左对齐。如何解决这个问题?
感谢您抽出时间。
My CSS looks like this:
#menu
{
width: 1024px;
height: 25px;
margin: 0 auto;
text-align: right;
background-color: Red;
}
My asp page looks like this, (in fragment):
<asp:Menu ID="mnuMainMenu" runat="server" BackColor="#F7F6F3"
DynamicHorizontalOffset="2" Font-Names="Verdana" Font-Size="Medium"
ForeColor="#7C6F57"
Orientation="Horizontal" StaticSubMenuIndent="10px" Font-Bold="True">
<StaticSelectedStyle BackColor="#5D7B9D" />
<StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
<DynamicHoverStyle BackColor="#7C6F57" ForeColor="White" />
<DynamicMenuStyle BackColor="#F7F6F3" />
<DynamicSelectedStyle BackColor="#5D7B9D" />
<DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
<StaticHoverStyle BackColor="#7C6F57" ForeColor="White" />
<Items>
<asp:MenuItem Text="Projekty" Value="Projekty"></asp:MenuItem>
<asp:MenuItem Text="Licencje" Value="Licencje"></asp:MenuItem>
<asp:MenuItem Text="Kontrahenci" Value="Kontrahenci"></asp:MenuItem>
</Items>
</asp:Menu>
I want to have menu aligned to the right side of my div tag. Aligment must be done automaticaly, if I add more menu items menu should realign itself.
This works as expected under split view in VS 2008, however in IE and FireFox the menu is aligned to the left. How to fix this problem?
Thanks for your time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以将菜单包装在 div 标签中并将其设置为向右浮动,但这使得某些 html 标签也可能浮动到其一侧。
You can wrap the menu in a div tag and set it to float right, this however makes it that certain html tags may float to its side as well.
我已将您的代码复制/粘贴到新的网络表单中。
也许这对你有用:
(我在菜单周围的 div 中添加了一个类,并将其浮动到右侧)
I have copied / paste your code into a new webform.
Maybe this will work for you:
(I have added a class to the div around your menu and floated it to the right)
这是一个旧线程,但当前执行此操作的方法是在菜单本身的“
Properties
”中,只需放入StaticMenuStyle-CssClass="menu"
并使用与上面相同的CSS样式。This is an old thread, but the current way of doing this is in the "
Properties
" of the Menu itself, just put inStaticMenuStyle-CssClass="menu"
and use the same css style as above.