开发者

Is it possible for a css class to work with asp:Menu control in .net 2.0

开发者 https://www.devze.com 2023-03-15 10:09 出处:网络
I\'m working on a migration of classic asp site to asp.net 2.0. There\'s a piece of CSS code associated with a div which I want to be used for an asp:Menu Control. I\'ve tried various permutations but

I'm working on a migration of classic asp site to asp.net 2.0. There's a piece of CSS code associated with a div which I want to be used for an asp:Menu Control. I've tried various permutations but can't get figure 开发者_运维知识库it out. The css is as follows:

.class{
  color: black;
  background-color: #A1A6AB;
  border: thin solid black;
  position: absolute;
  top: 1;
  width: 140;
  text-align: center;
  font: 9pt;
  z-index: 2;
  padding: 1;
  cursor: pointer;
  cursor: hand;
}

This needs to be associated with asp:Menu. Is it possible to do this?


There's a property of the menu control called CssClass. You can try that to start with and that will set the class for the entire menu when it is rendered to the browser.

There are also more granular styles, each with a CssClass property you can modify. They are

  • DynamicHoverStyle
  • DynamicSelectedStyle
  • DynamicMenuStyle
  • DynamicMenuItemStyle
  • LevelMenuItemStyles
  • LevelSelectedStyles
  • LevelSubMenuStyles
  • StaticHoverStyle
  • StaticMenuItemStyle
  • StaticMenuStyle
  • StaticSelectedStyle

Use these properties to your advantage.


Here's some sample CSS for a Menu control, including fix to stop it jumping in Firefox:

http://codersbarn.com/post/2009/07/30/Fix-for-TreeView-Jumping-in-Firefox.aspx


The closest possible that I've come to get the same feel and look is by adding the css properties directly through style in the asp:Menu.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号