Blogger Information
Blog 70
fans 1
comment 0
visits 53068
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
css基本属性-伸缩盒及浮动导航
葡萄枝子
Original
552 people have browsed it

css基本属性-伸缩盒及浮动导航

css基本属性

  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. <style>
  9. /* 字体,大小,粗细,字形 */
  10. p:nth-child(1) {
  11. font-family: 'Courier New', Courier, monospace;
  12. font-size: 16px;
  13. font-weight: bold;
  14. font-style: italic;
  15. }
  16. /* 字符间距 */
  17. p:nth-child(2) {
  18. letter-spacing: .5rem;
  19. }
  20. /* 单词间距 */
  21. p:nth-child(3) {
  22. word-spacing: .5rem;
  23. }
  24. /* 透明度 */
  25. p:nth-child(4) {
  26. opacity: .3;
  27. }
  28. /* 内容溢出 scroll 滚动,auto 自动 */
  29. p:nth-child(5) {
  30. width: 70px;
  31. height: 35px;
  32. overflow-y: hidden;
  33. border: 1px solid olive;
  34. background-color: #ccc;
  35. }
  36. /* 文字同一行显示,超出隐藏,溢出文本显示省略号 */
  37. p:nth-child(6) {
  38. width: 90px;
  39. overflow-x: hidden;
  40. white-space: nowrap;
  41. text-overflow: ellipsis;
  42. }
  43. /* 内容居中 */
  44. p:nth-child(7) {
  45. width: 200px;
  46. height: 50px;
  47. background-color: palevioletred;
  48. border: 1px solid purple;
  49. text-align: center;
  50. line-height: 50px;
  51. }
  52. /* 文本修饰 */
  53. p:nth-child(8) {
  54. background-color: #ccc;
  55. /* 文本缩进 */
  56. text-indent: 2rem;
  57. width: 120px;
  58. /* 长单词超过边界换行 */
  59. word-wrap: break-word;
  60. }
  61. p:nth-child(8)>span {
  62. /* 红色下划线 */
  63. text-decoration: underline red;
  64. /* 删除线 */
  65. /* text-decoration: line-through purple; */
  66. }
  67. ul {
  68. list-style-type:decimal;
  69. }
  70. body{
  71. /* 等价 */
  72. /* background-color: #f6f6f6;
  73. background-image: url(https://www.w3school.com.cn/i/eg_bg_01.gif);
  74. background-repeat: no-repeat;
  75. background-position: center;
  76. background-attachment: fixed; */
  77. background: #f6f6f6 url(https://www.w3school.com.cn/i/eg_bg_01.gif) no-repeat center fixed;
  78. }
  79. body>ul{
  80. width:200px;
  81. /* 转有序列表 */
  82. list-style: decimal;
  83. /* list-style: inside url(https://www.w3school.com.cn/i/eg_arrow.gif); */
  84. /* 等价 */
  85. list-style-position: inside;
  86. list-style-image: url(https://www.w3school.com.cn/i/eg_arrow.gif);
  87. }
  88. body>ul>li{
  89. background-color: salmon;
  90. padding: 8px;
  91. }
  92. </style>
  93. </head>
  94. <body>
  95. <p>Test text one.</p>
  96. <p>Test text two.</p>
  97. <p>Test text three.</p>
  98. <p>Test text four.</p>
  99. <p>Test text five.</p>
  100. <p>Test text six.</p>
  101. <p>Test text seven.</p>
  102. <p>test <span>texttesttesttexttest</span> eight.</p>
  103. <ul>
  104. <li>list-style-one</li>
  105. <li>list-style-two</li>
  106. <li>list-style-three</li>
  107. </ul>
  108. </body>
  109. </html>

css基本属性

伸缩盒及浮动定位导航

  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. <style>
  9. body>header {
  10. margin: 0 auto;
  11. width: 600px;
  12. }
  13. nav>ul {
  14. display: flex;
  15. height: 35px;
  16. justify-content: center;
  17. align-items: center;
  18. background-color: thistle;
  19. }
  20. nav>ul>li {
  21. padding: 5px 10px;
  22. position: relative;
  23. }
  24. ul>li {
  25. list-style: none;
  26. }
  27. ul>li>ul {
  28. position: absolute;
  29. left: -30px;
  30. top: 32px;
  31. width: 70px;
  32. display: none;
  33. }
  34. ul>li:hover>ul {
  35. display: block;
  36. }
  37. ul>li>ul>li {
  38. background-color: tomato;
  39. padding: 5px 8px;
  40. }
  41. ul>li>ul>li:hover {
  42. background-color: violet;
  43. }
  44. </style>
  45. </head>
  46. <body>
  47. <header>
  48. <nav>
  49. <ul>
  50. <li><a href="" title="首页">首页</a></li>
  51. <li><a href="" title="分类">分类</a>
  52. <ul>
  53. <li>分类一</li>
  54. <li>分类二</li>
  55. <li>分类三</li>
  56. </ul>
  57. </li>
  58. <li><a href="" title="标签">标签</a></li>
  59. <li><a href="" title="留言">留言</a></li>
  60. </ul>
  61. </nav>
  62. </header>
  63. </body>
  64. </html>

伸缩盒浮动导航

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