Skip to content

Commit 78c35b6

Browse files
committed
优化样式:1. 移除固定的间距值,调整按钮间距;2. 为竖直布局添加自适应高度和最大高度限制;3. 调整滚动条显示逻辑,优化内边距设置。
1 parent b833f96 commit 78c35b6

File tree

2 files changed

+51
-9
lines changed

2 files changed

+51
-9
lines changed

src/components/styles/buttons.scss

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,14 @@
7777
flex: 1;
7878
display: flex;
7979
flex-direction: column;
80-
gap: v.$spacing-xl; // 增加到24px的间距
8180
padding-right: v.$spacing-lg;
81+
// 移除固定的 gap 值
82+
justify-content: flex-start; // 从顶部开始排列
8283

8384
button {
8485
width: 100%;
8586
height: v.$button-size-md;
86-
padding: 0 v.$spacing-xl; // 增加左右内边距
87+
padding: 0 v.$spacing-xl;
8788
font-size: v.$font-sm;
8889
color: var(--el-text-color-regular);
8990
background-color: var(--el-fill-color-light);
@@ -94,7 +95,7 @@
9495
overflow: hidden;
9596
text-overflow: ellipsis;
9697
text-align: left;
97-
margin: 6px 0; // 增加到6px的外边距
98+
margin: v.$spacing-xs 0; // 减小按钮之间的间距
9899

99100
&:hover {
100101
color: var(--el-color-primary);
@@ -113,7 +114,7 @@
113114

114115
@media (hover: none) and (pointer: coarse) {
115116
min-height: 48px; // 增加移动端按钮高度
116-
margin: 4px 0;
117+
margin: v.$spacing-xs 0;
117118

118119
&:active {
119120
background-color: var(--el-color-primary-light-8);

src/components/styles/layout.scss

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,22 @@
1212
transition: all 0.3s ease;
1313
margin-top: v.$spacing-xs;
1414

15+
&:not(.horizontal-layout) {
16+
.variables-section {
17+
// 竖直布局时使用自适应高度
18+
height: auto;
19+
min-height: 120px; // 设置最小高度
20+
max-height: 320px; // 设置最大高度
21+
margin-bottom: v.$spacing-md; // 添加底部间距
22+
}
23+
24+
:deep(.calculator) {
25+
margin-top: 0; // 移除计算器顶部边距
26+
width: 100%; // 确保计算器宽度占满
27+
max-width: 320px; // 保持最大宽度限制
28+
}
29+
}
30+
1531
&.horizontal-layout {
1632
flex-direction: row;
1733
justify-content: center;
@@ -90,6 +106,20 @@
90106
width: 100%;
91107
max-width: 320px;
92108
}
109+
110+
.variables {
111+
position: relative;
112+
flex: 1;
113+
overflow: hidden;
114+
display: flex;
115+
flex-direction: column;
116+
117+
:deep(.el-scrollbar) {
118+
min-height: 80px; // 设置最小高度
119+
height: auto; // 自适应高度
120+
max-height: calc(100% - 48px); // 减去搜索框高度
121+
}
122+
}
93123
}
94124

95125
:deep(.calculator) {
@@ -131,16 +161,27 @@
131161

132162
.el-scrollbar__wrap {
133163
overflow-x: hidden;
164+
// 当内容高度小于容器高度时隐藏滚动条
165+
&:not(:hover):not(:focus-within) {
166+
scrollbar-width: none;
167+
&::-webkit-scrollbar {
168+
width: 0;
169+
height: 0;
170+
}
171+
}
134172
}
135173

136174
.el-scrollbar__view {
137-
padding: v.$spacing-md;
175+
padding: v.$spacing-md v.$spacing-md v.$spacing-xs; // 调整内边距,底部稍小
138176
display: flex;
139177
flex-direction: column;
140-
gap: v.$spacing-xs;
141-
142-
button {
143-
margin-right: v.$spacing-xs; // 确保按钮右边有足够空间显示边框
178+
// 当按钮少时,调整间距
179+
&:only-child {
180+
gap: v.$spacing-xs;
181+
}
182+
// 当按钮多时,保持原有间距
183+
&:not(:only-child) {
184+
gap: v.$spacing-xs;
144185
}
145186
}
146187
}

0 commit comments

Comments
 (0)