✨ 999 个小技巧,让你 Vibe 的产品更有质感 - 第 23 期 做好移动端网页适配的 4 个 Tips (附改造 Prompt,可以直接抄⬇️) 1. 去掉 iOS 的点击高亮。WebKit 会在点过的地方盖一块深色,悬停样式也会停住,元素看起来在闪、在跳。关掉高亮,悬停只留给鼠标。 2. 把顶部 Tab 移到底部。拇指常用的区域在屏幕下方。底部 Tab 随滚动收起和展开:往下读时收成小胶囊,往上滚或点一下再展开。 3. 做好 Safari 状态栏和工具栏的取色。 Safari 会读贴着屏幕顶边和底边的那一层来上色:状态栏想接上页面顶部的颜色;弹窗遮罩、底栏不要固定在窗口上,否则工具栏后面会多出一条灰带。 4. 如果有条件,支持 PWA。让用户能把网页添加到桌面,像 App 一样打开。 https://vibedesign.tips/023-mobile-web/
枯白啃设计

图标设计师 / 设计工程师

Prompt(2/4) 2. Taps on touch screens a. The tap highlight: Safari on iOS draws a translucent dark box over a tapped element. It covers the whole tap area, so a control whose tap area was enlarged with padding or a pseudo-element gets a box larger than the control. Turn it off for every page: html { -webkit-tap-highlight-color: transparent; } Keep a pressed look (:active) on every control, so a tap still has feedback. Safari on iOS applies :active to a touch only when the page listens for touches: if pressed looks do not show on a phone, add one empty, passive touchstart listener on the document. b. Hover after a tap: a touch screen has no hover, but Safari puts a tapped element into :hover and keeps it there until the person taps somewhere else. Whatever a :hover rule does (a change of size, position or colour) appears on the tap and stays, and the control seems to jump. - Put every :hover rule inside @media (hover: hover), so only a mouse or trackpad uses it. - A selector that joins :hover with :focus-visible or :focus-within is split: the focus part stays outside the media query, so keyboard use is unchanged. :active stays outside as well. - Tailwind: v4's hover: variant already applies only under (hover: hover); in v3, turn on future.hoverOnlyWhenSupported. Check the arbitrary variants and plain CSS that bypass it. c. Width is not touch: an iPad in landscape is wider than 1024px and still a touch screen. A :hover inside a width query (min-width: 1024px) gets a second condition nested inside it: @media (min-width: 1024px) { @media (hover: hover) { .chip:hover { … } } } d. Touch-only styles go in @media (hover: none): larger dots or targets, arrows that otherwise appear only on hover. e. Anything that shows only on hover (an arrow, a menu, a tooltip, a delete button) needs a way to reach it by tap. f. In scripts, element.matches(':hover') also stays true after a tap. Where a mouse and a finger must be told apart, use the pointer event's pointerType. g. Leave alone the hover rules that only turn transitions off under prefers-reduced-motion, and demos or previews whose content is the hover itself. 3. Bars at the foot On a phone the thumb reaches the foot of the screen, not the top. Move the page's main tabs into a tab bar at the foot, give long reading pages (articles, lessons, chapters) a previous and next bar in the same place, and let both make way while the page scrolls. Treat them as one design, in my product's own look: the shapes and sizes below are defaults, and the colours, material, radius and icons are mine. a. Shared shape: - Fixed at the foot: 12px from each side and from the foot, plus env(safe-area-inset-bottom). 56px tall, 4px padding, a capsule. - Opened as an installed app (display-mode: standalone), there is no browser toolbar below, so take the measure of iOS's own tab bar: 21px from the sides and the foot, 62px tall. - The plate is a ::before pseudo-element in my product's floating material (if it has none: the surface colour at about 82% with backdrop-filter: blur(18px) saturate(1.4)), a hairline (0 0 0 0.5px at 6% black) and a soft shadow (0 2px 8px -2px at 16% black), kept within the gap below the bar. The bar itself has no background (see 4b). - Pressed, keys show a pressed look but no shadow. Leave room under the page for the bar, so the last line clears it.
登录并发表评论

评论 · 0