如何在css中剪切边框画出的线?

yftpprvb  于 2023-10-21  发布在  其他
关注(0)|答案(1)|浏览(143)

我为我的网站创建了一个“进度条”。我想把这条线剪下来,让它以这些点开始和结束。尝试了不同的利润率和东西,但这不是办法。我也有一个问题与文本下面的点。我可以把它们强制 Package 成更窄的文本,以便它们彼此保持更大的距离吗?Current designDesired design
代码如下:

  1. .wraper {
  2. padding: 50px;
  3. text-align: center;
  4. font-family: sans-serif;
  5. max-width: 1300px;
  6. margin: 10px auto;
  7. }
  8. .container_wraper {
  9. border-top: 2px solid #293ff9;
  10. display: flex;
  11. list-style: none;
  12. padding: 0;
  13. justify-content: space-between;
  14. align-items: stretch;
  15. align-content: stretch;
  16. }
  17. .link {
  18. position: relative;
  19. margin-top: 10px;
  20. width: 100%;
  21. }
  22. .link a {
  23. font-weight: bold;
  24. font-size: 16px;
  25. font-family: "poppins", sans-serif;
  26. font-weight: 400;
  27. font-style: normal;
  28. color: #293ff9;
  29. letter-spacing: 2px;
  30. text-decoration: none;
  31. text-transform: uppercase;
  32. }
  33. /* .link:first-child {
  34. margin-left: -55px;
  35. }
  36. .link:last-child {
  37. margin-right: -55px;
  38. } */
  39. .link::after {
  40. content: "";
  41. width: 12px;
  42. height: 12px;
  43. background: #fff;
  44. position: absolute;
  45. border-radius: 10px;
  46. top: -18px;
  47. left: 50%;
  48. transform: translatex(-50%);
  49. border: 2px solid blue;
  50. }
  51. .link:hover::after {
  52. background: #293ff9;
  53. }
  54. .lead {
  55. display: flex;
  56. list-style: none;
  57. text-align: center;
  58. margin: 0 1px 0 1px;
  59. padding: 0;
  60. overflow-wrap: break-word;
  61. font-weight: bold;
  62. font-size: 10px;
  63. margin-top: 3px;
  64. font: sans-serif;
  65. letter-spacing: 1px;
  66. font-weight: 400;
  67. text-decoration: none;
  68. line-height: 1px;
  69. }
  1. <div class="wraper">
  2. <ul class="container_wraper">
  3. <li class="link"><a href="">Materiały</a></li>
  4. <li class="link"><a href="">Algorytmy</a></li>
  5. <li class="link active"><a href="">Szkolenia</a></li>
  6. </ul>
  7. <div class="lead">
  8. <p class="lead1">Lorem ipsum dolor sit amet consectetur adipisicing elit. Reprehenderit eligendi non id doloremque aliquid provident nobis consectetur recus.!</p>
  9. <p class="lead2">Lorem ipsum dolor sit amet consectetur adipisicing elit. Eius vel perferendis repellat laborum iure laudantium ex ipsa repellendus dignissimos iusto.</p>
  10. <p class="lead3">Lorem ipsum dolor sit amet consectetur adipisicing elit. Repudiandae officiis quae mollitia totam quis cumque a iste sapiente impedit neque illo eos .</p>
  11. </div>
  12. </div>
epfja78i

epfja78i1#

1.要修剪行的开头和结尾,可以使用以下CSS代码。我删除了border-bottom,并使用::before选择器添加了蓝线。此外,我使用transform属性来线性调整::before选择器创建的直线。我还删除了固定的top属性值18,并将其替换为transform属性,以确保点与各种大小对齐。
1.要实现更窄的文本,您可以使用letter-spacing,或者在我看来,您可以使用所需设计中存在的字体。

  1. .wraper {
  2. padding: 50px;
  3. text-align: center;
  4. font-family: sans-serif;
  5. max-width: 1300px;
  6. margin: 10px auto;
  7. }
  8. .container_wraper {
  9. display: flex;
  10. list-style: none;
  11. padding: 0;
  12. justify-content: space-between;
  13. align-items: stretch;
  14. align-content: stretch;
  15. }
  16. .link {
  17. position: relative;
  18. width: 100%;
  19. }
  20. .link::before {
  21. content: "";
  22. height: 2px;
  23. display: block;
  24. background-color: #293ff9;
  25. width: 100%;
  26. transform: translateX(50%);
  27. }
  28. .link:last-child:before {
  29. content: "";
  30. width: 0;
  31. }
  32. .link a {
  33. font-weight: bold;
  34. font-size: 16px;
  35. font-family: "poppins", sans-serif;
  36. font-weight: 400;
  37. font-style: normal;
  38. color: #293ff9;
  39. letter-spacing: 2px;
  40. text-decoration: none;
  41. text-transform: uppercase;
  42. margin-top: 10px;
  43. display: block;
  44. }
  45. /* .link:first-child {
  46. margin-left: -55px;
  47. }
  48. .link:last-child {
  49. margin-right: -55px;
  50. } */
  51. .link::after {
  52. content: "";
  53. width: 12px;
  54. height: 12px;
  55. background: #fff;
  56. position: absolute;
  57. border-radius: 10px;
  58. top: 0;
  59. left: 50%;
  60. transform: translate(-50%, -50%);
  61. border: 2px solid blue;
  62. }
  63. .link:hover::after {
  64. background: #293ff9;
  65. }
  66. .lead {
  67. display: flex;
  68. list-style: none;
  69. text-align: center;
  70. margin: 0 1px 0 1px;
  71. padding: 0;
  72. overflow-wrap: break-word;
  73. font-weight: bold;
  74. font-size: 10px;
  75. margin-top: 3px;
  76. font: sans-serif;
  77. letter-spacing: 1px;
  78. font-weight: 400;
  79. text-decoration: none;
  80. line-height: 1px;
  81. }
  1. <div class="wraper">
  2. <ul class="container_wraper">
  3. <li class="link"><a href="">Materiały</a></li>
  4. <li class="link"><a href="">Algorytmy</a></li>
  5. <li class="link active"><a href="">Szkolenia</a></li>
  6. </ul>
  7. <div class="lead">
  8. <p class="lead1">Lorem ipsum dolor sit amet consectetur adipisicing elit. Reprehenderit eligendi non id doloremque aliquid provident nobis consectetur recus.!</p>
  9. <p class="lead2">Lorem ipsum dolor sit amet consectetur adipisicing elit. Eius vel perferendis repellat laborum iure laudantium ex ipsa repellendus dignissimos iusto.</p>
  10. <p class="lead3">Lorem ipsum dolor sit amet consectetur adipisicing elit. Repudiandae officiis quae mollitia totam quis cumque a iste sapiente impedit neque illo eos .</p>
  11. </div>
  12. </div>
展开查看全部

相关问题