实例:
    image.png
    效果图:
    image.png

    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
    6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    7. <title>Document</title>
    8. <link rel="stylesheet" href="/static/css/style.css" type="text/css">
    9. </head>
    10. <body>
    11. <div class="user-card">
    12. <div class="user-card-head">
    13. asked 1 min ago
    14. </div>
    15. <div class="user-card-body">
    16. <div class="user-card-body-photo">
    17. <a href="https://www.acwing.com/user/myspace/index/79054/" target="_blank"><img
    18. src="https://cdn.acwing.com/media/user/profile/photo/79054_lg_d0f775e7d7.jpg" alt="头像"></a>
    19. </div>
    20. <div class="user-card-body-info">
    21. <div class="user-card-body-info-username">
    22. <a href="https://www.acwing.com/user/myspace/index/79054/" target="_blank">zdkk</a>
    23. </div>
    24. <div class="user-card-body-info-reputation">
    25. <span style="color: #6a737c; font-weight: bold;">2,058</span>
    26. <div class="user-card-body-info-reputation-item" style="background-color: #ffcc01"></div>
    27. 1
    28. <div class="user-card-body-info-reputation-item" style="background-color: #b4b8bc"></div>
    29. 5
    30. <div class="user-card-body-info-reputation-item" style="background-color: #d1a684"></div>
    31. 15
    32. </div>
    33. </div>
    34. </div>
    35. </div>
    36. </body>
    37. </html>
    1. .user-card {
    2. margin: 100px auto;
    3. width: 200px;
    4. height: 67.69px;
    5. background-color: #d9eaf7;
    6. box-sizing: border-box;
    7. padding: 5px 6px 7px 7px;
    8. border-radius: 2.5%;
    9. }
    10. .user-card-head {
    11. font-size: 12px;
    12. color: #6a737c;
    13. margin: 1px 0 4px 0;
    14. }
    15. .user-card-body-photo {
    16. float: left;
    17. }
    18. .user-card-body-info {
    19. float: left;
    20. margin-left: 8px;
    21. }
    22. .user-card-body-info-username {
    23. height: 14px;
    24. line-height: 14px;
    25. margin-bottom: 2px;
    26. }
    27. .user-card-body-info-username>a {
    28. font-size: 13px;
    29. color: #0074cc;
    30. font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    31. text-decoration: none;
    32. }
    33. .user-card-body-info-reputation {
    34. font-size: 12px;
    35. color: #838a95;
    36. height: 16px;
    37. line-height: 16px;
    38. }
    39. .user-card-body-photo img {
    40. width: 32px;
    41. height: 32px;
    42. border-radius: 3px;
    43. }
    44. .user-card-body-info-reputation-item {
    45. width: 6px;
    46. height: 6px;
    47. display: inline-block;
    48. border-radius: 50%;
    49. margin: 0 2px 0 2px;
    50. position: relative;
    51. top: -1px;
    52. }