Blogger Information
Blog 11
fans 0
comment 0
visits 4660
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
实战使用css选择器做一个下拉菜单
昊森
Original
405 people have browsed it

下拉菜单实战

html代码

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  7. <title>下拉菜单</title>
  8. <link rel="stylesheet" href="/使用csss选择器做一个下拉菜单/index.css" />
  9. </head>
  10. <body>
  11. <div class="box">
  12. <label for="xl">下拉菜单</label>
  13. <input type="checkbox" name="xl" id="xl" />
  14. <ul>
  15. <li><a href="">菜单1</a></li>
  16. <li><a href="">菜单2</a></li>
  17. <li><a href="">菜单3</a></li>
  18. <li><a href="">菜单4</a></li>
  19. <li><a href="">菜单5</a></li>
  20. </ul>
  21. </div>
  22. </body>
  23. </html>

css代码

  1. /* 首先隐藏input方框 */
  2. #xl {
  3. display: none;
  4. }
  5. /* 隐藏下拉菜单,需要的时候在呼出 */
  6. #xl + ul {
  7. display: none;
  8. }
  9. /* 点击label呼出菜单 */
  10. #xl:checked + ul {
  11. display: block;
  12. }
  13. /* 随便改下样式,让他好看点 */
  14. /* 给ui一个背景 */
  15. .box ul {
  16. background: #000;
  17. width: 60px;
  18. }
  19. .box label {
  20. padding: 5px 15px;
  21. background: #16dee1;
  22. color: #fff;
  23. }
  24. /* 取消li标签的小黑点 */
  25. .box li {
  26. list-style: none;
  27. }
  28. /* 取消A标签下划线 */
  29. .box li a {
  30. text-decoration: none;
  31. color: #fff;
  32. }

完整样式

Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post