• html实现邮件模版布局-flex布局&table布局-demo


    邮件模版布局

    flex - 布局简单方便  兼容性差

    table - 优点 就是兼容性好,其他没有优点

    注:使用图片需要png最好,使用svg图google邮箱会出现不能使用的情况

    效果图

    flex布局

    1. html>
    2. <html lang="en" xmlns:th="http://www.thymeleaf.org">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    6. <title>邮箱验证码title>
    7. <style>
    8. * {
    9. padding: 0;
    10. margin: 0;
    11. }
    12. body {
    13. background-color: #f5f5f5;
    14. }
    15. .wrap {
    16. width: 610px;
    17. margin: 0 auto;
    18. background-color: #fff;
    19. border-radius: 10px;
    20. }
    21. .head-top > img {
    22. width: 100%;
    23. margin-bottom: 24px;
    24. }
    25. .head {
    26. display: flex;
    27. justify-content: space-between;
    28. padding: 0 30px;
    29. }
    30. .head-left-title > h1 {
    31. color: #000;
    32. font-family: PingFang SC;
    33. font-size: 18px;
    34. font-weight: 600;
    35. padding: 50px 0 20px;
    36. }
    37. .head-left-title > h3 {
    38. color: #000;
    39. font-family: PingFang SC;
    40. font-size: 14px;
    41. font-weight: 500;
    42. }
    43. .code {
    44. padding: 0 30px 75px;
    45. }
    46. .code > h2 {
    47. color: #000;
    48. font-family: PingFang SC;
    49. font-size: 14px;
    50. font-weight: 500;
    51. margin-bottom: 10px;
    52. }
    53. .code > .code-num {
    54. width: 100%;
    55. height: 64px;
    56. background-color: #E0FAFE;
    57. display: flex;
    58. justify-content: center;
    59. align-items: center;
    60. }
    61. .code-num > span {
    62. color: #000;
    63. font-family: PingFang SC;
    64. font-size: 32px;
    65. font-weight: 600;
    66. letter-spacing: 12.8px;
    67. }
    68. .code > h4 {
    69. color: #000;
    70. font-family: PingFang SC;
    71. font-size: 14px;
    72. font-weight: 400;
    73. margin-top: 10px;
    74. }
    75. .footer-wrap {
    76. display: flex;
    77. flex-direction: column;
    78. align-items: center;
    79. padding-bottom: 40px;
    80. }
    81. .footer-wrap > h2 {
    82. color: #000;
    83. font-family: PingFang SC;
    84. font-size: 12px;
    85. font-weight: 400;
    86. padding-bottom: 5px;
    87. }
    88. .footer-wrap > h3 {
    89. color: #6C6C6C;
    90. font-family: PingFang SC;
    91. font-size: 12px;
    92. font-weight: 400;
    93. padding-top: 5px;
    94. }
    95. .footer-wrap > h3::before {
    96. display: inline-block;
    97. vertical-align: middle;
    98. content: '';
    99. width: 3px;
    100. height: 3px;
    101. border-radius: 50%;
    102. margin-right: 5px;
    103. background-color: #6C6C6C;
    104. }
    105. .footer-connect {
    106. display: flex;
    107. flex-direction: column;
    108. align-items: center;
    109. }
    110. .footer-connect > h2 {
    111. color: #000;
    112. font-family: PingFang SC;
    113. font-size: 12px;
    114. font-weight: 400;
    115. padding-bottom: 10px;
    116. }
    117. .footer-connect > h3 {
    118. color: #6C6C6C;
    119. font-family: PingFang SC;
    120. font-size: 12px;
    121. font-weight: 400;
    122. padding-bottom: 32px;
    123. }
    124. .footer-img {
    125. padding-bottom: 47px;
    126. }
    127. .footer-img > img {
    128. width: 30px;
    129. height: 30px;
    130. margin: 0 22px;
    131. }
    132. style>
    133. head>
    134. <body>
    135. <div class="wrap">
    136. <div class="head-top">
    137. <img src="https://d2t9byo8r5tyol.cloudfront.net/images/head-top.svg">
    138. div>
    139. <div class="head">
    140. <div class="head-left">
    141. <img src="images/logo.svg">
    142. <div class="head-left-title">
    143. <h1 th:text="${$1}">Subjecth1>
    144. <h3 th:if="${not #strings.isEmpty($2)}" th:text="${$2}">Describeh3>
    145. div>
    146. div>
    147. <div class="head-right">
    148. <img src="https://d2t9byo8r5tyol.cloudfront.net/images/sketch.svg">
    149. div>
    150. div>
    151. <div class="code">
    152. <h2>验证码:h2>
    153. <div class="code-num">
    154. <span th:text="${$3}">123456span>
    155. div>
    156. <h4 th:text="'验证码 ' + ${$4} + ' 分钟内有效,请勿泄露本邮件'">验证码 {} 分钟内有效,请勿泄露本邮件h4>
    157. <h4 th:if="${not #strings.isEmpty($5)}" th:text="'防钓鱼码: ' + ${$5}">防钓鱼码: {}h4>
    158. div>
    159. <div class="footer">
    160. <img src="https://d2t9byo8r5tyol.cloudfront.net/images/bg.svg">
    161. <div class="footer-wrap">
    162. <h2>致力于保护您的账户和交易安全h2>
    163. <h3>如果您怀疑自己收到了诈骗信息,请立即联系客服h3>
    164. <h3>如果您对邮件的真实性存有疑问,请勿犹豫,立即通过官方客服来核实信息h3>
    165. <h3>请勿与任何人分享您的验证码,包括官方客服和工作人员h3>
    166. div>
    167. <div class="footer-connect">
    168. <h2>感谢您使用!h2>
    169. <h3>如有疑问或需要帮助,请联系客服h3>
    170. <div class="footer-img">
    171. <img src="https://d2t9byo8r5tyol.cloudfront.net/images/t.svg">
    172. <img src="https://d2t9byo8r5tyol.cloudfront.net/images/x.svg">
    173. div>
    174. div>
    175. div>
    176. div>
    177. body>
    178. html>

    table布局-表格布局(推荐-兼容性高)

    1. <html>
    2. <head>
    3. <title>邮件模版title>
    4. head>
    5. <body>
    6. <table width="610" cellspacing="0" cellpadding="0"
    7. style="border-spacing: 0; color: #333333; margin-left: auto; margin-right: auto;border-radius: 10px;">
    8. <tr>
    9. <td colspan="2" width="610" height="10">
    10. <img src="https://d2t9byo8r5tyol.cloudfront.net/images/head-top.svg" width="610px">
    11. td>
    12. tr>
    13. <tr>
    14. <td style="padding: 30px 0 0 30px;">
    15. <img src="images/logo.svg" width="154px">
    16. td>
    17. <td rowspan="3" style="text-align: right;padding-top: 30px;">
    18. <img src="https://d2t9byo8r5tyol.cloudfront.net/images/sketch.svg" width="188px">
    19. td>
    20. tr>
    21. <tr>
    22. <td>
    23. <h1 style="font-size: 18px;
    24. font-weight: 600;color: #000;padding: 50px 0 20px;padding-left: 30px;" th:text="${$1}">Subjecth1>
    25. td>
    26. tr>
    27. <tr>
    28. <td>
    29. <h3 style="font-size: 14px;font-weight: 500;color: #000;padding-left: 30px;"
    30. th:if="${not #strings.isEmpty($2)}" th:text="${$2}">
    31. Describeh3>
    32. h3>
    33. td>
    34. tr>
    35. <tr>
    36. <td>
    37. <h2 style="font-size: 14px;
    38. font-weight: 500;color: #000;padding-left: 30px;">验证码:h2>
    39. td>
    40. tr>
    41. <tr>
    42. <td colspan="2" style="padding: 0 30px;">
    43. <div style="width: 100%;
    44. height: 64px;
    45. background-color: #E0FAFE;text-align: center;line-height: 64px;">
    46. <span style="font-size: 32px;
    47. font-weight: 600;
    48. letter-spacing: 12.8px;" th:text="${$3}">123456span>
    49. div>
    50. td>
    51. tr>
    52. <tr>
    53. <td>
    54. <h4 style="font-size: 14px;
    55. font-weight: 400;color: #000;margin-top: 10px;padding-left: 30px;"
    56. th:text="'验证码 ' + ${$4} + ' 分钟内有效,请勿泄露本邮件'">验证码 {}
    57. 分钟内有效,请勿泄露本邮件h4>
    58. td>
    59. tr>
    60. <tr>
    61. <td>
    62. <h4 style="font-size: 14px;
    63. font-weight: 400;color: #000;margin-top: 10px;padding-left: 30px;" th:if="${not #strings.isEmpty($5)}"
    64. th:text="'防钓鱼码: ' + ${$5}">防钓鱼码: {}h4>
    65. td>
    66. tr>
    67. <tr>
    68. <td colspan="2" width="610" height="110">
    69. <img src="https://d2t9byo8r5tyol.cloudfront.net/images/bg.svg" width="610px">
    70. td>
    71. tr>
    72. <tr>
    73. <td colspan="2" style="text-align: center;">
    74. <div style="padding-bottom: 40px;">
    75. <h2 style="font-size: 12px;
    76. font-weight: 400;color: #000;">AnyView致力于保护您的账户和交易安全h2>
    77. <h3 style="font-size: 12px;
    78. font-weight: 400;color: #6C6C6C;">• 如果您怀疑自己收到了诈骗信息,请立即联系客服h3>
    79. <h3 style="font-size: 12px;
    80. font-weight: 400;color: #6C6C6C;">• 如果您对邮件的真实性存有疑问,请勿犹豫,立即通过官方客服来核实信息h3>
    81. <h3 style="font-size: 12px;
    82. font-weight: 400;color: #6C6C6C;">• 请勿与任何人分享您的验证码,包括官方客服和工作人员h3>
    83. div>
    84. td>
    85. tr>
    86. <tr>
    87. <td colspan="2" style="text-align: center;">
    88. <div>
    89. <h2 style="font-size: 12px;
    90. font-weight: 400;color: #000;padding-bottom: 10px;">感谢您使用!h2>
    91. <h3 style="font-size: 12px;
    92. font-weight: 400;color: #6C6C6C;padding-bottom: 32px;">如有疑问或需要帮助,请联系客服h3>
    93. <div style="padding-bottom: 47px;">
    94. <img src="https://d2t9byo8r5tyol.cloudfront.net/images/t.svg" width="30px">
    95. <img style="margin-left: 22px;" src="https://d2t9byo8r5tyol.cloudfront.net/images/x.svg"
    96. width="30px">
    97. div>
    98. div>
    99. td>
    100. tr>
    101. table>
    102. body>
    103. html>
  • 相关阅读:
    Vue——vue3中的ref和reactive数据理解以及父子组件之间props传递的数据
    Springboot 实践(17)spring boot整合Nacos配置中心
    Substring 在BCL和CLR里面搞了啥
    zabbix监控部署keepalived高可用
    人事管理系统是什么?HR系统有什么用?
    ArrayList源码
    【Java】线程、线程安全、线程状态
    bindParam() 和 bindValue() 的区别
    docker常用命令(云容器)
    JavaScript在ES6及后续新增的常用新特性
  • 原文地址:https://blog.csdn.net/JackieDYH/article/details/132734952