1、必填标志添加一个红色的*
- css:
.bitian::before {
content: '*' !important;
color: #ff4f4f !important;
}
- html
<div className={`${style.xxx} bitian`}>企业ID:</div>
2、文字超出隐藏
- 让文字只显示一行,超出显示省略号
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
- 让文字最多只显示两行,超出后显示省略号
overflow:hidden;
text-overflow:ellipsis;
display:-webkit-box;
-webkit-box-orient:vertical;
-webkit-line-clamp:2;
3、and-desgin组件常用组件及设置
table表格默认样式设置
方案一:
:global {
// 表格样式统一
.ant-table-wrapper {
height: 100%;
// 去除底部分页
.ant-table-pagination {
display: none;
}.ant-spin-nested-loading {
height: 100%;
}
.ant-spin-container {
height: 100%;
}
.ant-table {
height: 100%;
.ant-table-container {
height: 100%;
.ant-table-body {
height: 100%;
}
}
}
}
.ant-table-body {
overflow: auto !important;
}
.ant-table-tbody > tr {
cursor: pointer;
}
.ant-table-thead > tr > th {
.ant-table-filter-trigger-container {
position: unset;
width: 0.5px;
}
.ant-table-filter-column-title {
padding: 0 0 0 16px;
}
.ant-table-column-sorters {
padding: 0;
}
font-size: 14px !important;
}
.ant-table-tbody > tr.ant-table-row:hover > td {
background-color: #f5faff !important;
}
.ant-table-thead .ant-table-cell {
padding: 0;
font-weight: bold;
}
.ant-table-tbody > tr > td {
padding: 0;
color: #535353;
font-size: 13px;
}
.ant-table-tbody > tr > td:nth-child(1) {
padding: 0;
}
.ant-table-tbody > tr > td:nth-child(1),
.ant-table-tbody > tr > td:nth-child(2),
.ant-table-tbody > tr > td:nth-child(4) {
div {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 1;
line-clamp: 1;
-webkit-box-orient: vertical;
line-height: 20px;
}
}
.ant-table-placeholder {
// table为空时去除边距
& > td:nth-child(1) {
padding-left: 0 !important;
}
.ant-table-expanded-row-fixed {
margin: 0 !important;
padding: 0 !important;
}
}
}
- 方案二:
:global {
.ant-table-body {
//表格滚动条问题
overflow: auto scroll !important;
height: calc(100vh - 255px) !important;
}
.ant-popover-open {
background: none !important;
} // 这个看需求写
.ant-btn-text:hover {
background: none !important;
} // 这个看需求写
// 测试环境表格表头突然变高
.ant-table-thead > tr > th {
.ant-table-column-sorters {
padding: 0 !important;
}
}
}
- 方案三:
.table_box {
:global {
.ant-table-body {
height: 100vh;
}
// 测试环境表格表头突然变高
.ant-table-thead > tr > th {
.ant-table-column-sorters {
padding: 0 !important;
}
}
}
}
#### table设置
<Table
scroll={{x: '900px', y: 'calc(100vh)'}}
className={style.content_1_table_info}
rowKey="id"
dataSource={microFissionStores.activeList || []}
columns={this.columns1}
pagination={false}
/>
4、title样式前面hover蓝色代码块
.title::before {
content: '';
display: inline-block;
width: 5px;
height: 15px;
background: #4096ff;
vertical-align: middle;
margin-bottom: 2px;
margin-right: 5px;
}
5、原生JS实现tooltip功能(css实现)
- html代码如下:
<h1>
HTML/CSS tooltip
</h1>
<p>
Hover <span class="tooltip" tooltip-data="Tooltip Content">Here</span> to see the tooltip.
</p>
<p>
You can also hover <span class="tooltip" tooltip-data="This is another Tooltip Content">here</span> to see another example.
</p>
- css 代码如下:
.tooltip {
position: relative;
border-bottom: 1px dotted black;
}
.tooltip:before {
content: attr(tooltip-data);
position: absolute;
width: 250px;
background-color: #efba93;
color: #fff;
text-align: center;
padding: 15px;
line-height: 1.1;
border-radius: 5px;
z-index: 1;
opacity: 0;
transition: opacity .5s;
bottom: 125%;
left: 50%;
margin-left: -60px;
font-size: 0.70em;
visibility: hidden;
}
.tooltip:after {
content: "";
position: absolute;
bottom: 75%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
opacity: 0;
transition: opacity .5s;
border-color: #000 transparent transparent transparent;
visibility: hidden;
}
.tooltip:hover:before,
.tooltip:hover:after {
opacity: 1;
visibility: visible;
}
6、侧边栏的 Hover 效果
- html代码如下:
<div class="css-dynamic-sidebar">
<nav>
<a class="" href="#">Menu #1</a>
<a class="" href="#">Menu #2</a>
<a class="" href="#">Menu #3</a>
</nav>
<div class="site-content">
<p>Hover over the sidebar</p>
<p>Also work with Tab selector (for accessibility)</p>
</div>
</div>
- css 代码如下:
.css-dynamic-sidebar {
overflow: hidden;
position: relative;
height: 50em;
max-width: 50em;
margin: auto;
}
.site-content {
margin: auto;
}
nav {
display: flex;
flex-direction: column;
position: absolute;
right: 100%;
padding: 1em;
background-color: #f3f3f3;
transform: translateX(1em);
transition: 0.2s transform;
}
nav:hover,
nav:focus-within {
transform: translateX(100%);
}
a {
white-space: pre;
color: black;
}
p {
font-size: 2em;
font-family: monospace;
text-align: center;
}