1、必填标志添加一个红色的*

  • css:
    1. .bitian::before {
    2. content: '*' !important;
    3. color: #ff4f4f !important;
    4. }
  • html
    1. <div className={`${style.xxx} bitian`}>企业ID:</div>

2、文字超出隐藏

  • 让文字只显示一行,超出显示省略号
    1. overflow: hidden;
    2. white-space: nowrap;
    3. text-overflow: ellipsis;
  • 让文字最多只显示两行,超出后显示省略号
    1. overflow:hidden;
    2. text-overflow:ellipsis;
    3. display:-webkit-box;
    4. -webkit-box-orient:vertical;
    5. -webkit-line-clamp:2;

3、and-desgin组件常用组件及设置

table表格默认样式设置

  • 方案一:
    :global {
    // 表格样式统一
    .ant-table-wrapper {
    height: 100%;
    // 去除底部分页
    .ant-table-pagination {
    display: none;
    }

    1. .ant-spin-nested-loading {
    2. height: 100%;
    3. }
    4. .ant-spin-container {
    5. height: 100%;
    6. }
    7. .ant-table {
    8. height: 100%;
    9. .ant-table-container {
    10. height: 100%;
    11. .ant-table-body {
    12. height: 100%;
    13. }
    14. }
    15. }
    16. }
    17. .ant-table-body {
    18. overflow: auto !important;
    19. }
    20. .ant-table-tbody > tr {
    21. cursor: pointer;
    22. }
    23. .ant-table-thead > tr > th {
    24. .ant-table-filter-trigger-container {
    25. position: unset;
    26. width: 0.5px;
    27. }
    28. .ant-table-filter-column-title {
    29. padding: 0 0 0 16px;
    30. }
    31. .ant-table-column-sorters {
    32. padding: 0;
    33. }
    34. font-size: 14px !important;
    35. }
    36. .ant-table-tbody > tr.ant-table-row:hover > td {
    37. background-color: #f5faff !important;
    38. }
    39. .ant-table-thead .ant-table-cell {
    40. padding: 0;
    41. font-weight: bold;
    42. }
    43. .ant-table-tbody > tr > td {
    44. padding: 0;
    45. color: #535353;
    46. font-size: 13px;
    47. }
    48. .ant-table-tbody > tr > td:nth-child(1) {
    49. padding: 0;
    50. }
    51. .ant-table-tbody > tr > td:nth-child(1),
    52. .ant-table-tbody > tr > td:nth-child(2),
    53. .ant-table-tbody > tr > td:nth-child(4) {
    54. div {
    55. overflow: hidden;
    56. text-overflow: ellipsis;
    57. display: -webkit-box;
    58. -webkit-line-clamp: 1;
    59. line-clamp: 1;
    60. -webkit-box-orient: vertical;
    61. line-height: 20px;
    62. }
    63. }
    64. .ant-table-placeholder {
    65. // table为空时去除边距
    66. & > td:nth-child(1) {
    67. padding-left: 0 !important;
    68. }
    69. .ant-table-expanded-row-fixed {
    70. margin: 0 !important;
    71. padding: 0 !important;
    72. }
    73. }
    74. }
  • 方案二:
  1. :global {
  2. .ant-table-body {
  3. //表格滚动条问题
  4. overflow: auto scroll !important;
  5. height: calc(100vh - 255px) !important;
  6. }
  7. .ant-popover-open {
  8. background: none !important;
  9. } // 这个看需求写
  10. .ant-btn-text:hover {
  11. background: none !important;
  12. } // 这个看需求写
  13. // 测试环境表格表头突然变高
  14. .ant-table-thead > tr > th {
  15. .ant-table-column-sorters {
  16. padding: 0 !important;
  17. }
  18. }
  19. }
  • 方案三:
  1. .table_box {
  2. :global {
  3. .ant-table-body {
  4. height: 100vh;
  5. }
  6. // 测试环境表格表头突然变高
  7. .ant-table-thead > tr > th {
  8. .ant-table-column-sorters {
  9. padding: 0 !important;
  10. }
  11. }
  12. }
  13. }
  1. #### table设置
  1. <Table
  2. scroll={{x: '900px', y: 'calc(100vh)'}}
  3. className={style.content_1_table_info}
  4. rowKey="id"
  5. dataSource={microFissionStores.activeList || []}
  6. columns={this.columns1}
  7. pagination={false}
  8. />

4、title样式前面hover蓝色代码块

  1. .title::before {
  2. content: '';
  3. display: inline-block;
  4. width: 5px;
  5. height: 15px;
  6. background: #4096ff;
  7. vertical-align: middle;
  8. margin-bottom: 2px;
  9. margin-right: 5px;
  10. }

5、原生JS实现tooltip功能(css实现)

  • html代码如下:
  1. <h1>
  2. HTML/CSS tooltip
  3. </h1>
  4. <p>
  5. Hover <span class="tooltip" tooltip-data="Tooltip Content">Here</span> to see the tooltip.
  6. </p>
  7. <p>
  8. You can also hover <span class="tooltip" tooltip-data="This is another Tooltip Content">here</span> to see another example.
  9. </p>
  • css 代码如下:
  1. .tooltip {
  2. position: relative;
  3. border-bottom: 1px dotted black;
  4. }
  5. .tooltip:before {
  6. content: attr(tooltip-data);
  7. position: absolute;
  8. width: 250px;
  9. background-color: #efba93;
  10. color: #fff;
  11. text-align: center;
  12. padding: 15px;
  13. line-height: 1.1;
  14. border-radius: 5px;
  15. z-index: 1;
  16. opacity: 0;
  17. transition: opacity .5s;
  18. bottom: 125%;
  19. left: 50%;
  20. margin-left: -60px;
  21. font-size: 0.70em;
  22. visibility: hidden;
  23. }
  24. .tooltip:after {
  25. content: "";
  26. position: absolute;
  27. bottom: 75%;
  28. left: 50%;
  29. margin-left: -5px;
  30. border-width: 5px;
  31. border-style: solid;
  32. opacity: 0;
  33. transition: opacity .5s;
  34. border-color: #000 transparent transparent transparent;
  35. visibility: hidden;
  36. }
  37. .tooltip:hover:before,
  38. .tooltip:hover:after {
  39. opacity: 1;
  40. visibility: visible;
  41. }

点击查看详细内容

6、侧边栏的 Hover 效果

  • html代码如下:
  1. <div class="css-dynamic-sidebar">
  2. <nav>
  3. <a class="" href="#">Menu #1</a>
  4. <a class="" href="#">Menu #2</a>
  5. <a class="" href="#">Menu #3</a>
  6. </nav>
  7. <div class="site-content">
  8. <p>Hover over the sidebar</p>
  9. <p>Also work with Tab selector (for accessibility)</p>
  10. </div>
  11. </div>
  • css 代码如下:
  1. .css-dynamic-sidebar {
  2. overflow: hidden;
  3. position: relative;
  4. height: 50em;
  5. max-width: 50em;
  6. margin: auto;
  7. }
  8. .site-content {
  9. margin: auto;
  10. }
  11. nav {
  12. display: flex;
  13. flex-direction: column;
  14. position: absolute;
  15. right: 100%;
  16. padding: 1em;
  17. background-color: #f3f3f3;
  18. transform: translateX(1em);
  19. transition: 0.2s transform;
  20. }
  21. nav:hover,
  22. nav:focus-within {
  23. transform: translateX(100%);
  24. }
  25. a {
  26. white-space: pre;
  27. color: black;
  28. }
  29. p {
  30. font-size: 2em;
  31. font-family: monospace;
  32. text-align: center;
  33. }

点击查看详细内容