找回密码
 会员注册
查看: 172|回复: 0

asp.net 网页菜单栏实现

[复制链接]

1389

主题

5

回帖

496万

积分

管理员

积分
4962990
发表于 2024-2-29 08:47:08 | 显示全部楼层 |阅读模式

1、添加CSS样式文件到项目中

2、为Menu菜单添加样式

 

附录:

Default.aspx

  1. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
  2. <!DOCTYPE html>
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head runat="server">
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  6. <title></title>
  7. <link href="~/Styles/StyleSheet.css" rel="stylesheet" type="text/css" />
  8. </head>
  9. <body>
  10. <form id="form1" runat="server">
  11. <div class="hideSkiplink">
  12. <asp:Menu ID="Menu1" runat="server" CssClass="menu" Orientation="Horizontal" IncludeStyleBlock="False" EnableViewState="False">
  13. <Items>
  14. <asp:MenuItem Text="主页" Value="主页">
  15. <asp:MenuItem Text="新建项1" Value="新建项1">
  16. <asp:MenuItem Text="菜单3" Value="菜单3"></asp:MenuItem>
  17. </asp:MenuItem>
  18. <asp:MenuItem Text="新建项2" Value="新建项2"></asp:MenuItem>
  19. </asp:MenuItem>
  20. <asp:MenuItem Text="帮助" Value="帮助"></asp:MenuItem>
  21. <asp:MenuItem Text="其它" Value="其它"></asp:MenuItem>
  22. </Items>
  23. </asp:Menu>
  24. </div>
  25. </form>
  26. </body>
  27. </html>
复制代码

 

stylesSheet.css

  1. /* DEFAULTS
  2. ----------------------------------------------------------*/
  3. body
  4. {
  5. background: #b6b7bc;
  6. font-size: .80em;
  7. font-family: "Helvetica Neue", "Lucida Grande", "Segoe UI", Arial, Helvetica, Verdana, sans-serif;
  8. margin: 0px;
  9. padding: 0px;
  10. color: #696969;
  11. }
  12. a:link, a:visited
  13. {
  14. color: #034af3;
  15. }
  16. a:hover
  17. {
  18. color: #1d60ff;
  19. text-decoration: none;
  20. }
  21. a:active
  22. {
  23. color: #034af3;
  24. }
  25. p
  26. {
  27. margin-bottom: 10px;
  28. line-height: 1.6em;
  29. }
  30. /* HEADINGS
  31. ----------------------------------------------------------*/
  32. h1, h2, h3, h4, h5, h6
  33. {
  34. font-size: 1.5em;
  35. color: #666666;
  36. font-variant: small-caps;
  37. text-transform: none;
  38. font-weight: 200;
  39. margin-bottom: 0px;
  40. }
  41. h1
  42. {
  43. font-size: 1.6em;
  44. padding-bottom: 0px;
  45. margin-bottom: 0px;
  46. }
  47. h2
  48. {
  49. font-size: 1.5em;
  50. font-weight: 600;
  51. }
  52. h3
  53. {
  54. font-size: 1.2em;
  55. }
  56. h4
  57. {
  58. font-size: 1.1em;
  59. }
  60. h5, h6
  61. {
  62. font-size: 1em;
  63. }
  64. /* this rule styles <h1> and <h2> tags that are the
  65. first child of the left and right table columns */
  66. .rightColumn > h1, .rightColumn > h2, .leftColumn > h1, .leftColumn > h2
  67. {
  68. margin-top: 0px;
  69. }
  70. /* PRIMARY LAYOUT ELEMENTS
  71. ----------------------------------------------------------*/
  72. .page
  73. {
  74. width: 960px;
  75. background-color: #fff;
  76. margin: 20px auto 0px auto;
  77. border: 1px solid #496077;
  78. }
  79. .header
  80. {
  81. position: relative;
  82. margin: 0px;
  83. padding: 0px;
  84. background: #4b6c9e;
  85. width: 100%;
  86. }
  87. .header h1
  88. {
  89. font-weight: 700;
  90. margin: 0px;
  91. padding: 0px 0px 0px 20px;
  92. color: #f9f9f9;
  93. border: none;
  94. line-height: 2em;
  95. font-size: 2em;
  96. }
  97. .main
  98. {
  99. padding: 0px 12px;
  100. margin: 12px 8px 8px 8px;
  101. min-height: 420px;
  102. }
  103. .leftCol
  104. {
  105. padding: 6px 0px;
  106. margin: 12px 8px 8px 8px;
  107. width: 200px;
  108. min-height: 200px;
  109. }
  110. .footer
  111. {
  112. color: #4e5766;
  113. padding: 8px 0px 0px 0px;
  114. margin: 0px auto;
  115. text-align: center;
  116. line-height: normal;
  117. }
  118. .center
  119. {
  120. position:fixed;
  121. left:50%;
  122. top:50%;
  123. padding: 6px 0px;
  124. margin: 12px 8px 8px 8px;
  125. width: 200px;
  126. min-height: 100px;
  127. min-width: 100px
  128. }
  129. /* TAB MENU
  130. ----------------------------------------------------------*/
  131. div.hideSkiplink
  132. {
  133. background-color:#3a4f63;
  134. width:100%;
  135. }
  136. div.menu
  137. {
  138. padding: 4px 0px 4px 8px;
  139. }
  140. div.menu ul
  141. {
  142. list-style: none;
  143. margin: 0px;
  144. padding: 0px;
  145. width: auto;
  146. }
  147. div.menu ul li a, div.menu ul li a:visited
  148. {
  149. background-color: #465c71;
  150. border: 1px #4e667d solid;
  151. color: #dde4ec;
  152. display: block;
  153. line-height: 1.35em;
  154. padding: 4px 20px;
  155. text-decoration: none;
  156. white-space: nowrap;
  157. }
  158. div.menu ul li a:hover
  159. {
  160. background-color: #bfcbd6;
  161. color: #465c71;
  162. text-decoration: none;
  163. }
  164. div.menu ul li a:active
  165. {
  166. background-color: #465c71;
  167. color: #cfdbe6;
  168. text-decoration: none;
  169. }
  170. /* FORM ELEMENTS
  171. ----------------------------------------------------------*/
  172. fieldset
  173. {
  174. margin: 1em 0px;
  175. padding: 1em;
  176. border: 1px solid #ccc;
  177. }
  178. fieldset p
  179. {
  180. margin: 2px 12px 10px 10px;
  181. }
  182. fieldset.login label, fieldset.register label, fieldset.changePassword label
  183. {
  184. display: block;
  185. }
  186. fieldset label.inline
  187. {
  188. display: inline;
  189. }
  190. legend
  191. {
  192. font-size: 1.1em;
  193. font-weight: 600;
  194. padding: 2px 4px 8px 4px;
  195. }
  196. input.textEntry
  197. {
  198. width: 320px;
  199. border: 1px solid #ccc;
  200. }
  201. input.passwordEntry
  202. {
  203. width: 320px;
  204. border: 1px solid #ccc;
  205. }
  206. div.accountInfo
  207. {
  208. width: 42%;
  209. }
  210. /* MISC
  211. ----------------------------------------------------------*/
  212. .clear
  213. {
  214. clear: both;
  215. }
  216. .title
  217. {
  218. display: block;
  219. float: left;
  220. text-align: left;
  221. width: auto;
  222. }
  223. .loginDisplay
  224. {
  225. font-size: 1.1em;
  226. display: block;
  227. text-align: right;
  228. padding: 10px;
  229. color: White;
  230. }
  231. .loginDisplay a:link
  232. {
  233. color: white;
  234. }
  235. .loginDisplay a:visited
  236. {
  237. color: white;
  238. }
  239. .loginDisplay a:hover
  240. {
  241. color: white;
  242. }
  243. .failureNotification
  244. {
  245. font-size: 1.2em;
  246. color: Red;
  247. }
  248. .bold
  249. {
  250. font-weight: bold;
  251. }
  252. .submitButton
  253. {
  254. text-align: right;
  255. padding-right: 10px;
  256. }
复制代码

 

 


来源:https://blog.csdn.net/scimence/article/details/82352446
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?会员注册

×
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 会员注册

本版积分规则

QQ|手机版|心飞设计-版权所有:微度网络信息技术服务中心 ( 鲁ICP备17032091号-12 )|网站地图

GMT+8, 2024-12-26 12:42 , Processed in 2.445418 second(s), 27 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表