DIV 设置四个角的border

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <title>DIV 设置四个角的border</title>
  8. <style>
  9. .chart-border-block {
  10. position: relative;
  11. width: 500px;
  12. height: 500px;
  13. /* background: #28305c; */
  14. box-sizing: border-box;
  15. border: 2px solid #565B77;
  16. border-radius: 10px;
  17. }
  18. .chart-border-block:before {
  19. content: '';
  20. position: absolute;
  21. width: 80%;
  22. height: 100%;
  23. bottom: -2px;
  24. top: -2px;
  25. left: 10%;
  26. border-bottom: 2px solid #fff;
  27. border-top: 2px solid #fff;
  28. pointer-events: none;
  29. }
  30. .chart-border-block:after {
  31. content: '';
  32. position: absolute;
  33. width: 100%;
  34. height: 80%;
  35. left: -2px;
  36. right: -2px;
  37. top: 10%;
  38. border-left: 2px solid #fff;
  39. border-right: 2px solid #fff;
  40. pointer-events: none;
  41. }
  42. </style>
  43. </head>
  44. <body>
  45. <div class="chart-border-block">
  46. </div>
  47. </body>
  48. </html>

INPUT 输入框自定义

描述:去掉自己的原生样式,然后左右边框半高

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <title>INPUT 输入框自定义</title>
  8. <style>
  9. html,
  10. body {
  11. padding: 0;
  12. margin: 0;
  13. }
  14. body {
  15. height: calc(100vh);
  16. display: flex;
  17. justify-content: center;
  18. align-items: center;
  19. }
  20. .container {
  21. position: relative;
  22. width: 400px;
  23. height: 30px;
  24. background: gray;
  25. box-sizing: border-box;
  26. border-bottom: 1px solid #333;
  27. }
  28. .container:before {
  29. position: absolute;
  30. content: "";
  31. width: 100%;
  32. height: 50%;
  33. bottom: 0px;
  34. border-left: 1px solid #333;
  35. }
  36. .container:after {
  37. position: absolute;
  38. content: "";
  39. width: 100%;
  40. height: 50%;
  41. bottom: -1px;
  42. border-right: 1px solid #333;
  43. }
  44. input {
  45. width: 100%;
  46. height: 100%;
  47. line-height: 100%;
  48. border: 0;
  49. box-sizing: border-box;
  50. padding: 0px 2px;
  51. background: gray;
  52. }
  53. </style>
  54. </head>
  55. <body>
  56. <div class="container">
  57. <input type="text">
  58. </div>
  59. </body>
  60. </html>