测试:响应式按钮/style.css
来自EaseCation Wiki
更多操作
/* === 整体卡片样式 === */
.mc-card {
border: 1.5px solid #888;
background-color: #c6c6c6;
box-shadow:
inset 1.5px 1.5px 0 #fff,
inset -1.5px -1.5px 0 #555;
display: flex;
flex-direction: column;
text-decoration: none !important;
overflow: hidden;
height: 100%;
}
/* === 图片区域(保持2:1比例) === */
.mc-card-top {
height: 60px;
display: flex;
align-items: center;
justify-content: center;
padding: 4px;
}
/* 让图片区域内的链接铺满整个容器(点击空白背景也能跳转) */
.mc-card-top a {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
text-decoration: none;
}
/* 图片本身样式(保留像素化渲染) */
.mc-card-top img {
max-width: 44px;
max-height: 44px;
image-rendering: pixelated;
}
/* === 文字按钮区域(高度精准30px) === */
.mc-card-bottom {
height: 30px;
line-height: 30px;
font-size: 14px;
padding: 0;
background-color: #dcdcdc;
border-top: 1.5px solid #888;
text-align: center;
font-weight: bold;
color: #333;
font-family: sans-serif;
cursor: pointer;
transition: all 0.1s ease;
box-shadow:
inset 1.5px 1.5px 0 #ffffff,
inset -1.5px -1.5px 0 #555555;
white-space: nowrap;
overflow: hidden;
}
/* 让链接铺满整个底部按钮区域(点击空白处也能跳转) */
.mc-card-bottom a {
display: block;
width: 100%;
height: 100%;
line-height: 30px;
color: inherit;
text-decoration: none;
font-weight: bold;
font-family: sans-serif;
}
/* === 点击动画(按下时凹陷效果) === */
.mc-card-bottom:active {
transform: translateY(2px);
box-shadow:
inset 1.5px 1.5px 0 #555555,
inset -1.5px -1.5px 0 #ffffff;
background-color: #c0c0c0;
}
/* === 响应式网格容器(手机强制3列,电脑自适应多列) === */
.mc-nav-grid {
display: grid;
gap: 8px;
justify-content: center;
width: 100%;
max-width: 100%;
padding: 0 5px;
/*
minmax(90px, 1fr) 的意义:
- 手机屏宽 320px,去除 padding 和 gap 后剩余约 294px
- 294 ÷ 3 = 98px,因此 90px 的最小列宽足够塞进 3 列
- 电脑上 auto-fit 会自动扩充列数,填满整行
*/
grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
}