css - Responsive named grid-template-columns?
问题描述
How does the naming grid-template-columns
work in relation to media queries and responsiveness?
I'm trying to learn this and started with a very basic 2 column grid, from tablet and above its a 50/50 grid however, tablet below i want it on top of each other.
I'm using the fr unit so 1fr for each side when i want it 50/50 but how do it tell it to ignore that on mobile?
auto
doesn't seem to work and neither does 100%
.
This is what i have so far. Grid setup:
.f-2-grid {
grid-template-columns: [left-side] auto [right-side] auto;
}
@media (min-width: 46.25em) {
.f-2-grid {
grid-template-columns: [left-side] 1fr [right-side] 1fr;
}
}
Targeting the 2 columns:
.footer-contact.f-2-grid-box {
grid-column: left-side;
}
.follow-icons.f-2-grid-box {
grid-column: right-side;
}
I'm sure this is a simple idea and apologies for the simple question but cannot seem to find the correct way from all the tutorials I've read.
解决方案
谢谢你,它让我走上了正确的道路......这成功了......
.f-2-grid {
/*nothing needed here*/
}
@media (min-width: 46.25em) {
.f-2-grid {
grid-template-columns: [left-side] 1fr [right-side] 1fr;
}
}
@media (min-width: 46.25em) {
.footer-contact.f-2-grid-box {
grid-column: left-side;
}
}
@media (min-width: 46.25em) {
.follow-icons.f-2-grid-box {
grid-column: right-side;
}
}
推荐阅读
- javascript - 从 php 代码中的 php 变量定义 javascript 变量
- sql-server - 用于报告的 SQL Server 过程
- sql - SQL 显示每个类
- android - Android:带有形状的淡入/淡出会产生白色闪光
- python - 如果在 24 小时内重复,则保持价值
- python - Python - 将简单的游戏代码更改为带有方法的类?
- ssas - 在 SSAS 中开发渐变维度
- flutter - 使用颤振生成发票/订单/付款请求
- javascript - mouseup 上的 clearTimeout 无法正常工作
- apache-spark-sql - 使用 Pyspark-SQL 估计性别平衡