display: inline‐flex - daniel-qa/Vue GitHub Wiki
.curriculum-match-btn {
display: inline-flex !important;
align-items: center !important; /* 垂直置中 */
justify-content: center !important; /* 水平置中 */
}
- 效果:
按鈕保持行內元素特性(可以和其他元素並排)
啟用 Flexbox,讓內部文字可以使用 align-items 和 justify-content 來置中
文字會完美地水平和垂直置中
- 視覺化比較
沒有 flexbox:
┌─────────────┐
│ 課綱匹配 │ ← 文字可能偏上或偏下
└─────────────┘
使用 inline-flex + align-items: center:
┌─────────────┐
│ 課綱匹配 │ ← 文字完美置中
└─────────────┘