Skip to content

Commit 3a77422

Browse files
authored
Improve mobile homepage responsiveness (#8)
1 parent a8a2cb2 commit 3a77422

4 files changed

Lines changed: 98 additions & 28 deletions

File tree

docs/.vitepress/theme/components/HeroCarousel.vue

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,20 +92,25 @@ onUnmounted(() => {
9292
display: flex;
9393
flex-direction: column;
9494
align-items: center;
95+
justify-content: center;
96+
gap: 10px;
9597
}
9698
9799
.carousel-link {
98100
position: absolute;
99-
top: -4px;
100-
right: -16px;
101+
top: -8px;
102+
right: 0;
101103
display: inline-flex;
102104
align-items: center;
103105
gap: 4px;
106+
max-width: min(100%, 220px);
104107
font-size: 13px;
105108
font-weight: 500;
106109
color: var(--vp-c-brand-1);
107110
text-decoration: none;
108-
white-space: nowrap;
111+
white-space: normal;
112+
text-align: right;
113+
line-height: 1.4;
109114
transition: color 0.25s;
110115
z-index: 1;
111116
}
@@ -162,14 +167,29 @@ onUnmounted(() => {
162167
}
163168
164169
@media (max-width: 768px) {
170+
.hero-carousel {
171+
justify-content: flex-start;
172+
gap: 8px;
173+
}
174+
165175
.carousel-link {
166-
right: 0;
176+
position: static;
177+
order: -1;
178+
align-self: center;
179+
justify-content: center;
180+
max-width: min(100%, 240px);
167181
font-size: 12px;
168-
top: -2px;
182+
text-align: center;
169183
}
170184
171185
.carousel-stage {
172-
padding-top: 8px;
186+
padding-top: 0;
187+
width: 100%;
188+
}
189+
190+
.carousel-img {
191+
width: 100%;
192+
height: 100%;
173193
}
174194
}
175195
</style>

docs/.vitepress/theme/index.css

Lines changed: 56 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -75,53 +75,67 @@
7575
}
7676

7777
/* 隐藏导航栏中的完整菜单,使用汉堡菜单代替 */
78-
.VPNavBar .menu {
78+
.VPNavBar .menu,
79+
.VPNavBar .custom-toggles {
7980
display: none !important;
8081
}
8182

83+
.VPNavBarTitle .title {
84+
max-width: calc(100vw - 156px);
85+
white-space: nowrap;
86+
overflow: hidden;
87+
text-overflow: ellipsis;
88+
}
89+
8290
/* 首页 hero 区域适配 */
8391
.VPHero {
84-
padding-top: 48px !important;
85-
padding-bottom: 32px !important;
92+
padding-top: 32px !important;
93+
padding-bottom: 24px !important;
94+
}
95+
96+
.VPHero .container,
97+
.VPHero .main {
98+
width: 100% !important;
8699
}
87100

88-
/* 缩小移动端 hero 图片区域,避免图片占据过多屏幕空间 */
89101
.VPHero .image {
90-
margin: -40px -24px -36px !important;
102+
margin: 0 auto 8px !important;
103+
order: -1;
91104
}
92105

93106
.VPHero .image-container {
94-
width: 200px !important;
95-
height: 200px !important;
107+
width: min(64vw, 260px) !important;
108+
height: min(64vw, 260px) !important;
96109
}
97110

98111
.VPHero .image-bg {
99-
width: 140px !important;
100-
height: 140px !important;
112+
width: min(44vw, 180px) !important;
113+
height: min(44vw, 180px) !important;
101114
}
102115

103116
.VPHero .name {
104-
font-size: 32px !important;
105-
line-height: 1.2 !important;
117+
font-size: clamp(28px, 8vw, 36px) !important;
118+
line-height: 1.15 !important;
106119
}
107120

108121
.VPHero .text {
109-
font-size: 22px !important;
110-
line-height: 1.3 !important;
122+
font-size: clamp(22px, 7vw, 30px) !important;
123+
line-height: 1.2 !important;
111124
}
112125

113126
.VPHero .tagline {
114-
font-size: 14px !important;
115-
line-height: 1.5 !important;
127+
font-size: 15px !important;
128+
line-height: 1.7 !important;
116129
margin-top: 12px !important;
117-
padding: 0 12px !important;
130+
padding: 0 8px !important;
131+
max-width: 100% !important;
118132
}
119133

120134
.VPHero .actions {
121135
display: flex !important;
122136
flex-direction: column !important;
123137
gap: 12px !important;
124-
padding: 0 24px !important;
138+
padding: 0 !important;
125139
margin-top: 20px !important;
126140
}
127141

@@ -134,20 +148,26 @@
134148
width: 100% !important;
135149
display: flex !important;
136150
justify-content: center !important;
137-
padding: 10px 20px !important;
138-
font-size: 15px !important;
151+
padding: 12px 20px !important;
152+
font-size: 16px !important;
139153
height: auto !important;
140154
line-height: 1.5 !important;
155+
border-radius: 999px !important;
141156
}
142157

143158
/* 首页 feature 卡片全宽显示 */
159+
.VPHomeFeatures,
160+
.VPFeatures,
144161
.VPFeatures .container {
145162
max-width: 100% !important;
163+
padding-left: 0 !important;
164+
padding-right: 0 !important;
146165
}
147166

148167
.VPFeatures .items {
149168
display: flex !important;
150169
flex-direction: column !important;
170+
gap: 16px !important;
151171
}
152172

153173
.VPFeatures .items .item {
@@ -157,7 +177,23 @@
157177
}
158178

159179
.VPFeature {
160-
padding: 20px 24px !important;
180+
padding: 20px !important;
181+
border-radius: 24px !important;
182+
}
183+
}
184+
185+
@media (max-width: 480px) {
186+
.VPNavBarTitle .title {
187+
max-width: calc(100vw - 132px);
188+
}
189+
190+
.VPHero .container {
191+
padding-left: 24px !important;
192+
padding-right: 24px !important;
193+
}
194+
195+
.VPFeature {
196+
padding: 18px !important;
161197
}
162198
}
163199

docs/en/index.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,18 @@ features:
9090
font-weight: 500;
9191
}
9292
@media (max-width: 768px) {
93+
.home-qr-section {
94+
padding: 0 12px;
95+
}
9396
.qr-container {
9497
gap: 24px;
98+
margin-top: 24px;
99+
}
100+
.qr-card {
101+
width: 100%;
95102
}
96103
.qr-card img {
97-
width: 180px;
104+
width: min(180px, 100%);
98105
}
99106
}
100107
</style>

docs/index.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,18 @@ features:
9090
font-weight: 500;
9191
}
9292
@media (max-width: 768px) {
93+
.home-qr-section {
94+
padding: 0 12px;
95+
}
9396
.qr-container {
9497
gap: 24px;
98+
margin-top: 24px;
99+
}
100+
.qr-card {
101+
width: 100%;
95102
}
96103
.qr-card img {
97-
width: 180px;
104+
width: min(180px, 100%);
98105
}
99106
}
100107
</style>

0 commit comments

Comments
 (0)