如何在 asp:Menu 控件中填充图像和文本
我有一个 asp:Menu 控件,其中有四个不同的菜单项。 每个菜单项都有图形和文字说明。
<Items>
<asp:MenuItem Text="New Authorization Form" Value="default.aspx" NavigateUrl="~/Default.aspx" ImageUrl="~/Images/TextPad.png"></asp:MenuItem>
<asp:MenuItem Text="Manage My Forms" Value="myrequests.aspx" NavigateUrl="~/MyRequests.aspx" ImageUrl="~/Images/Pencil.png"></asp:MenuItem>
</Items>
我的问题是图标和文本之间没有填充,而且看起来很丑! 有谁知道如何在菜单项的图像和文本之间强制进行一些填充? 我已经查看了 asp:Menu 控件上的所有属性,但我无法找到与此相关的属性,但我可能只是错过了它。
I have an asp:Menu control that has four different menu items in it. Each menu item has a graphic and a text description.
<Items>
<asp:MenuItem Text="New Authorization Form" Value="default.aspx" NavigateUrl="~/Default.aspx" ImageUrl="~/Images/TextPad.png"></asp:MenuItem>
<asp:MenuItem Text="Manage My Forms" Value="myrequests.aspx" NavigateUrl="~/MyRequests.aspx" ImageUrl="~/Images/Pencil.png"></asp:MenuItem>
</Items>
My problem is the icon and text have no padding between them and it just looks ugly! Does anyone know how I can force a bit of padding between the image and text of the menu item? I've looked at all of the attributes on the asp:Menu control, but I haven't been able to find one for this, but I may have just missed it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我想出了一个答案,但这并不是我所希望的。 我在我的 css 中添加了 img 标签的样式,如下所示:
我仍然有点沮丧,因为 asp:Menu 控件中没有允许您指定图像和菜单项文本之间的填充的属性。
I came up with an answer, but it's not what I was hoping for exactly. I added a style for img tags to my css like so:
I'm still a little bummed that there are no attributes within the asp:Menu control that allow you to specify the padding between the image and menu item text.
你可以尝试创建一个皮肤,然后你可以添加一个CSS类并以你想要的任何方式设置它的样式
you could try creating a skin and then you could add a css class to and style it any way you want
菜单中的图像项由图标类控制,修改该类的属性应该可以解决问题。 我将 padding-right 设置为 5px 以间隔图像和文本
the image item in the Menu is controlled by the class icon, modifying the properties of this class should solve the problem. I set padding-right to 5px to space image and text