Files
persionalBrand/apps/taro/src/app.css
T
que01 bb94d80e13 fix: 修正 H5 按钮高度令牌不生效
共享按钮令牌声明在 app.css 的 page 选择器里,而 H5 渲染树没有 page 元素,导致
var(--brand-button-height) 解析失败、min-height 退化成 auto:H5 预览按钮实际高 38px
(内容撑开),与小程序 88rpx(375px 视口等于 44px)不一致,也违反模板完成度规则的
双端 reset 一致要求。

- 令牌改为同时声明在 page 与 body 上,值仍只写一次;微信端取 page,H5 取 body;
- 新增浏览器守卫,断言首页按钮 min-height 解析为 44px 且实际高度一致;
- 在模板完成度规则中记录该根因,避免声明被挪回单一 page 选择器。

验证:weapp 产物输出 page,body{--brand-button-height:88rpx},H5 输出 page,body{2.2rem};
浏览器实测 375px 视口下 min-height/height 均为 44px,430px 视口为 50.45px,与小程序
rpx 缩放一致;把声明改回 page-only 后守卫按预期失败(Received: "auto"),恢复后 12 项
浏览器回归全部通过;六类产物指纹残留为 0;format、lint、typecheck 通过。
2026-10-13 23:44:12 +08:00

95 lines
1.7 KiB
CSS

page {
background: #fafaf9;
}
/* H5 渲染树里没有 page 元素,令牌必须同时声明在真实根节点 body 上,双端按钮高度才一致。 */
page,
body {
--brand-button-height: 88px;
--brand-button-compact-height: 46px;
}
body {
margin: 0;
}
view,
text,
image,
input,
textarea,
button {
box-sizing: border-box;
}
button {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
min-height: var(--brand-button-height);
text-align: center;
appearance: none;
margin: 0;
padding: 0;
border: 0;
border-radius: 0;
line-height: 1.5;
background: transparent;
color: inherit;
font: inherit;
}
button::after {
border: 0;
}
image {
display: block;
}
.editor-target-selected {
outline: 3px solid #1677ff;
outline-offset: -3px;
cursor: pointer;
}
.runtime-state {
min-height: 70vh;
padding: 80px 32px;
color: #78716c;
font-size: 28px;
text-align: center;
}
.runtime-state button {
margin-top: 24px;
}
.preview-context {
padding: 12px 32px;
color: #78716c;
background: #fff;
border-bottom: 1px solid #eee;
font-size: 22px;
}
/* postcss-pxtransform disable */
/* H5 导航固定在视口底部,滚动页面必须保留真实像素的避让空间。 */
.taro_tabbar_page {
box-sizing: border-box;
padding-bottom: calc(66px + env(safe-area-inset-bottom));
}
@media (min-width: 430px) {
html {
font-size: 22.933333px !important;
background: #e7e5e4;
}
body {
max-width: 430px;
margin: 0 auto;
}
#app {
background: #fafaf9;
}
.taro-tabbar__tabbar,
.food-detail .bar,
.editorial-detail .bar {
width: 430px;
left: 50%;
right: auto;
transform: translateX(-50%);
}
}
/* postcss-pxtransform enable */