下拉菜单

ゝ一世哀愁。 2023-02-17 14:30 290阅读 0赞

在这里插入图片描述

  1. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> *{
  2. margin: 0;
  3. padding: 0;
  4. }
  5. div {
  6. width: 80px;
  7. }
  8. a {
  9. display: block;
  10. width: 80px;
  11. height: 50px;
  12. font-size: 14px;
  13. text-align: center;
  14. line-height: 50px;
  15. text-decoration: none;
  16. border: 1px solid orange;
  17. }
  18. ul {
  19. display: none;
  20. }
  21. li {
  22. width: 80px;
  23. text-align: center;
  24. list-style: none;
  25. border: 1px solid orange;
  26. }
  27. </style>
  28. </head>
  29. <body>
  30. <div>
  31. <a href="#">test</a>
  32. <ul>
  33. <li><a href="#">私信</a></li>
  34. <li><a href="#">评论</a></li>
  35. <li><a href="#">@我</a></li>
  36. </ul>
  37. </div>
  38. <script>
  39. var a = document.querySelector('div');
  40. var ul = document.querySelector('ul');
  41. var li = document.querySelectorAll('li'); a.onmouseover = function() {
  42. ul.style.display = 'block';
  43. }
  44. a.onmouseout = function () {
  45. ul.style.display = 'none';
  46. }
  47. for(var i = 0 ; i < li.length ; i++){
  48. li[i].onmouseover = function () {
  49. this.style.backgroundColor = '#fff5da';
  50. this.style.color = "red";
  51. }
  52. li[i].onmouseout = function() {
  53. this.style.backgroundColor = 'white';
  54. this.style.color = "#4c4c4c";
  55. }
  56. }
  57. </script>
  58. </body>
  59. </html>

发表评论

表情:
评论列表 (有 0 条评论,290人围观)

还没有评论,来说两句吧...

相关阅读

    相关 Bootstrap菜单

    dropdown 类用来指定一个下拉菜单; 使用一个按钮或链接来打开下拉菜单, 按钮或链接需要添加 .dropdown-toggle 和 data-toggle=“drop

    相关 BootStrap菜单

    Bootstrap 下拉菜单将具体讲解下拉菜单的交互,使用下拉菜单(Dropdown)插件,您可以向任何组件(比如导航栏、标签页、胶囊式导航菜单、按钮等)添加下拉菜单