一致性基础样式

通常情况下,H5、小程序、客户端拥有各自的默认样式,各端呈现效果不一。所以,cml框架会给各端添加一致性基础样式。

基础样式包括以下方面:

类型默认值
布局 display: flex; flex-direction: column;
盒模型box-sizing: border-box;
定位position: relative;
文本 display: block; font-size: 16px; white-space: pre-wrap;

针对H5端添加的基础样式如下

  1. .cml-root {
  2. width: 100%;
  3. overflow-x: hidden;
  4. -webkit-tap-highlight-color: transparent;
  5. font-family: BlinkMacSystemFont, 'Source Sans Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  6. }
  7. .cml-base {
  8. text-align: left;
  9. font-size: 0.4rem; /*15px*/
  10. letter-spacing: 0.02rem;
  11. }
  12. .cml-base,
  13. .cml-base::before,
  14. .cml-base::after {
  15. box-sizing: border-box;
  16. text-size-adjust: none;
  17. }
  18. .cml-view {
  19. display: flex;
  20. box-sizing: border-box;
  21. position: relative;
  22. flex-direction: column;
  23. flex-shrink: 0;
  24. flex-grow: 0;
  25. flex-basis: auto;
  26. align-items: stretch;
  27. align-content: flex-start;
  28. border: 0 solid black;
  29. margin: 0;
  30. padding: 0;
  31. min-width: 0;
  32. }
  33. .cml-text {
  34. display: block;
  35. box-sizing: border-box;
  36. position: relative;
  37. white-space: pre-wrap; /* not using 'pre': support auto line feed. */
  38. word-wrap: break-word;
  39. overflow: hidden; /* it'll be clipped if the height is not high enough. */
  40. flex-shrink: 0;
  41. flex-grow: 0;
  42. flex-basis: auto;
  43. border: 0 solid black;
  44. margin: 0;
  45. padding: 0;
  46. min-width: 0;
  47. }

针对小程序添加的基础样式如下:

  1. .cml-base {
  2. text-align: left;
  3. font-size: 32rpx;
  4. letter-spacing: 1rpx;
  5. font-family: BlinkMacSystemFont, 'Source Sans Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  6. }
  7. .cml-base,
  8. .cml-base::before,
  9. .cml-base::after {
  10. box-sizing: border-box;
  11. text-size-adjust: none;
  12. }
  13. .cml-view {
  14. display: flex;
  15. box-sizing: border-box;
  16. position: relative;
  17. flex-direction: column;
  18. flex-shrink: 0;
  19. flex-grow: 0;
  20. flex-basis: auto;
  21. align-items: stretch;
  22. align-content: flex-start;
  23. border: 0 solid black;
  24. margin: 0;
  25. padding: 0;
  26. min-width: 0;
  27. }
  28. .cml-text {
  29. display: block;
  30. box-sizing: border-box;
  31. position: relative;
  32. white-space: pre-wrap; /* not using 'pre': support auto line feed. 保留空白符序列,但是正常地进行换行 */
  33. word-wrap: break-word; /* 在长单词或 URL 地址内部进行换行。 */
  34. overflow: hidden; /* it'll be clipped if the height is not high enough. */
  35. flex-shrink: 0;
  36. flex-grow: 0;
  37. flex-basis: auto;
  38. border: 0 solid black;
  39. margin: 0;
  40. padding: 0;
  41. min-width: 0;
  42. }

说明如下:

class名代表含义
.cml-rootH5端 app 根节点
.cml-base任一节点
.cml-viewview元素
.cml-texttext元素