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-background"></div>
    13. <div class="user-card-body">
    14. <div class="user-card-body-left">
    15. <img src="https://cdn.acwing.com/media/user/profile/photo/79054_lg_d0f775e7d7.jpg" alt="头像">
    16. </div>
    17. <div class="user-card-body-right">
    18. <div class="user-card-body-right-text">
    19. <div class="user-card-body-right-text-username">
    20. 带刀的猪
    21. <span>Lv5</span>
    22. </div>
    23. <div class="user-card-body-right-text-reputation">
    24. <span class="user-card-body-right-text-reputation-item">
    25. <span>148</span>
    26. <span>关注</span>
    27. </span>
    28. <span class="user-card-body-right-text-reputation-item">
    29. <span>4</span>
    30. <span>粉丝</span>
    31. </span>
    32. <span class="user-card-body-right-text-reputation-item">
    33. <span>9</span>
    34. <span>获赞</span>
    35. </span>
    36. </div>
    37. </div>
    38. <div class="user-card-body-right-button">
    39. <button>+关注</button>
    40. <button>发消息</button>
    41. </div>
    42. </div>
    43. </div>
    44. </div>
    45. </body>
    46. </html>
    1. .user-card {
    2. height: 215px;
    3. width: 366px;
    4. box-shadow: 2px 2px 5px lightgray;
    5. border-radius: 5px;
    6. }
    7. .user-card-background {
    8. background-image: url('/static/images/bilibili.jpg');
    9. background-size: cover;
    10. width: 100%;
    11. height: 85px;
    12. }
    13. .user-card-body {
    14. width: 100%;
    15. height: calc(100% - 85px);
    16. box-sizing: border-box;
    17. padding-top: 12px;
    18. }
    19. .user-card-body-left {
    20. width: 70px;
    21. height: 100%;
    22. float: left;
    23. text-align: center;
    24. }
    25. .user-card-body-left>img {
    26. width: 48px;
    27. height: 48px;
    28. border-radius: 50%;
    29. border: 1px solid lightsteelblue;
    30. }
    31. .user-card-body-right {
    32. width: calc(100% - 70px);
    33. height: 100%;
    34. float: left;
    35. }
    36. .user-card-body-right-text {
    37. width: 100%;
    38. height: 70%;
    39. box-sizing: border-box;
    40. }
    41. .user-card-body-right-text-username {
    42. font-size: 16px;
    43. color: #222222;
    44. font-weight: bold;
    45. margin-bottom: 10px;
    46. }
    47. .user-card-body-right-text-reputation {}
    48. .user-card-body-right-text-username>span {
    49. font-style: italic;
    50. font-size: 12px;
    51. color: #8bd29b;
    52. padding: 0 0 0 6px;
    53. }
    54. .user-card-body-right-text-reputation-item>span:nth-child(1) {
    55. font-size: 12px;
    56. color: #222222;
    57. }
    58. .user-card-body-right-text-reputation-item>span:nth-child(2) {
    59. font-size: 12px;
    60. color: #9499a0;
    61. margin-right: 20px;
    62. }
    63. .user-card-body-right-button {
    64. width: 100%;
    65. }
    66. .user-card-body-right-button button {
    67. width: 102px;
    68. height: 30px;
    69. margin-right: 6px;
    70. border-radius: 5px;
    71. /* 鼠标放在该元素上变成小手 */
    72. cursor: pointer;
    73. }
    74. .user-card-body-right-button>button:nth-child(1) {
    75. background-color: #00A1D6;
    76. color: white;
    77. font-size: 16px;
    78. border-style: none;
    79. }
    80. .user-card-body-right-button>button:nth-child(2) {
    81. background-color: white;
    82. color: #6d757a;
    83. font-size: 16px;
    84. border: 1px #ccd0d7 solid;
    85. }
    86. .user-card-body-right-button>button:nth-child(1):hover {
    87. opacity: 0.8;
    88. transition: 400ms;
    89. }
    90. .user-card-body-right-button>button:nth-child(2):hover {
    91. border-color: #00b5e5;
    92. color: #00b5e5;
    93. transition: 400ms;
    94. }