demo.html 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>两端对齐</title>
  6. <meta name="viewport"
  7. content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, minimal-ui, shrink-to-fit=no">
  8. <style>
  9. * {
  10. margin: 0;
  11. padding: 0;
  12. }
  13. .step {
  14. width: 300px;
  15. height: 30px;
  16. margin: 20px auto 0;
  17. text-align: justify; /* 主要还是因为这个所以两端对齐 */
  18. /*font-size: 0;*/ /* 原本想去掉 inline-block 元素间的空格,后来发现 IE 有问题 */
  19. }
  20. .step i {
  21. display: inline-block;
  22. width: 16px;
  23. height: 16px;
  24. overflow: hidden;
  25. font-style: normal;
  26. line-height: 16px;
  27. font-size: 12px;
  28. text-align: center;
  29. border-radius: 50%;
  30. background-color: #333;
  31. color: #fff;
  32. *zoom: 1;
  33. }
  34. .step:after {
  35. content: "";
  36. }
  37. .step:after,
  38. .step b {
  39. display: inline-block;
  40. position: relative;
  41. top: -25px;
  42. *top: -9px;
  43. width: 100%;
  44. height: 1px;
  45. overflow: hidden;
  46. font-size: 0;
  47. line-height: 0;
  48. background-color: #ccc;
  49. z-index: -1;
  50. *zoom: 1;
  51. }
  52. </style>
  53. </head>
  54. <body>
  55. <div class="step">
  56. <i>1</i>
  57. <i>2</i>
  58. <i>3</i>
  59. <i>4</i>
  60. <i>5</i>
  61. <i>6</i>
  62. <i>7</i><!--[if lte IE 7]>
  63. <b></b><![endif]--></div>
  64. <div class="step">
  65. <i>1</i>
  66. <i>2</i>
  67. <i>3</i>
  68. <i>4</i>
  69. <i>5</i><!--[if lte IE 7]><b></b><![endif]--></div>
  70. <div class="step"><i>1</i>
  71. <i>2</i>
  72. <i>3</i>
  73. <i>4</i><!--[if lte IE 7]><b></b><![endif]--></div>
  74. <div class="step">
  75. <i>1</i>
  76. <i>2</i>
  77. <i>3</i><!--[if lte IE 7]><b></b><![endif]--></div>
  78. <div class="step"><i>1</i> <i>2</i><!--[if lte IE 7]><b></b><![endif]--></div>
  79. </body>
  80. </html>