01.html 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>菜鸟教程(runoob.com)</title>
  6. <style>
  7. body {
  8. margin: 0;
  9. }
  10. ul {
  11. list-style-type: none;
  12. margin: 0;
  13. padding: 0;
  14. width: 25%;
  15. background-color: #f1f1f1;
  16. position: fixed;
  17. height: 100%;
  18. /*overflow: auto;*/
  19. }
  20. /*li a {*/
  21. /*display: block;*/
  22. /*color: #000;*/
  23. /*padding: 8px 16px;*/
  24. /*text-decoration: none;*/
  25. /*}*/
  26. /*li a.active {*/
  27. /*background-color: #4CAF50;*/
  28. /*color: white;*/
  29. /*}*/
  30. /*li a:hover:not(.active) {*/
  31. /*background-color: #555;*/
  32. /*color: white;*/
  33. /*}*/
  34. </style>
  35. </head>
  36. <body>
  37. <ul>
  38. <li><a class="active" href="#home">主页</a></li>
  39. <li><a href="#news">新闻</a></li>
  40. <li><a href="#contact">联系</a></li>
  41. <li><a href="#about">关于</a></li>
  42. </ul>
  43. <div style="margin-left:25%;padding:1px 16px;height:1000px;">
  44. <h2>Fixed Full-height Side Nav</h2>
  45. <h3>Try to scroll this area, and see how the sidenav sticks to the page</h3>
  46. <p>Notice that this div element has a left margin of 25%. This is because the side navigation is set to 25% width. If you remove the margin, the sidenav will overlay/sit on top of this div.</p>
  47. <p>Also notice that we have set overflow:auto to sidenav. This will add a scrollbar when the sidenav is too long (for example if it has over 50 links inside of it).</p>
  48. <p>Some text..</p>
  49. <p>Some text..</p>
  50. <p>Some text..</p>
  51. <p>Some text..</p>
  52. <p>Some text..</p>
  53. <p>Some text..</p>
  54. <p>Some text..</p>
  55. </div>
  56. </body>
  57. </html>