CSS 常见问题
#
常见问题- CSS Reference
#
display: table 不支持 max-height 和 overflow- 建议使用 flex 模拟 table
- thead 和 tbody 可能不同步
overflow-x: hidden
确保两个同步
width: 100%
可能显示不完整 - 滚动出的内容背景不完整- max-content 显示完整
- 如果 width 不够会导致右侧滚动条看不到
- thead 和 tbody 可能不同步
- CSS3 display:table, overflow-y:scroll doesn't work
#
父节点 min-heigh, 子节点百分比 heigh 无效- Fix
- parent 添加
height:1px;
- parent flex flex-col, child flex-1
- 如果 parent 的 min-heigh 是数值而非百分比,child 使用
min-height: inherit;
也可以
- parent 添加
#
默认字体font-family: -apple-system, BlinkMacSystemFont, Avenir Next, Avenir, Helvetica, sans-serif;
#
字体单位如何选择- 考虑因素
- 支持缩放
- 支持不同设备 - 缩放
- 响应式样式 - 缩放+断点
- 设计图
- 单位
- rem - 基于
<html>
font-size 的相对单位
- rem - 基于
- 数值
- 375 / 16 = 23.4375
- 参考
- Is text sizing dead?
- Myth: Pixels units for text are bad for accessibility
- Myth: Don’t use pixels in media queries
- 实际不影响
- vitalets/react-native-extended-stylesheet#19
- 移动端长度适配方案
- Taro 设计稿及尺寸单位
- Is text sizing dead?
#
Scroll Snaphttps://web.dev/snap-after-layout/
https://caniuse.com/#feat=css-snappoints https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Scroll_Snap
https://codepen.io/argyleink/pen/RwPWqKe