欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

flex,简单丑陋的二级下拉菜单,

程序员文章站 2022-03-24 09:45:52
...
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Title</title>
  6. <style>
  7. * {
  8. padding: 0;
  9. margin: 0;
  10. text-decoration: none;
  11. list-style: none;
  12. } body{
  13. background-color: #ccc;
  14. }
  15. .container{
  16. display: flex;
  17. background-color: #888888;
  18. text-align: center;
  19. justify-content: center;
  20. align-items: center;
  21. }
  22. .father{
  23. padding: 10px 25px;
  24. position: relative;
  25. }
  26. .son{
  27. position: absolute;
  28. background-color: #888888;
  29. top: 41px;
  30. left: 15px;
  31. padding: 5px;
  32. display: none;
  33. }
  34. .son>li{
  35. width: 60px;
  36. padding: 5px;
  37. font-size: 14px;
  38. /*display: none;*/
  39. }
  40. .son>li:hover{
  41. background-color: white;
  42. color: red;
  43. }
  44. .father:hover .son{
  45. display: block;
  46. }
  47. </style>
  48. </head>
  49. <body>
  50. <nav class="container">
  51. <li class="father"> 歌星大全
  52. <ul class="son">
  53. <li>周姐伦</li>
  54. <li>那英</li>
  55. <li>汪峰</li>
  56. </ul>
  57. </li>
  58. <li class="father"> 游戏大全
  59. <ul class="son">
  60. <li>拳皇97</li>
  61. <li>套熊猫</li>
  62. <li>接水管</li>
  63. </ul>
  64. </li>
  65. <li class="father"> 影视大全
  66. <ul class="son">
  67. <li>杀生</li>
  68. <li>那一夜</li>
  69. <li>封门村</li>
  70. </ul>
  71. </li>
  72. </nav></body>
  73. </html>