css - 使用 CSS Grid 包裹两列 | 最大含量和最小最大值
问题描述
我正在尝试使用 Grid 显示具有以下属性的两列网格。
- 第一列:显示
max-content
宽度(文本全长) - 第二栏;占用剩余空间使用
min-max(100px 1fr)
最后一个属性是在宽度规则被破坏后将内容包装成两行。
过去一天左右我一直在为此苦苦挣扎,这应该很简单!但我仍然找不到解决方案。任何帮助将不胜感激!。这就是我到目前为止所拥有的。
.grid-container-1 .grid-item-1 {
grid-area:one;
background-color: red;
}
.grid-item-2 {
grid-area:two;
background-color: blue;
}
.grid-container-1 {
display:grid;
grid-template-columns: max-content repeat(auto-fit, minmax(100px 1fr));
grid-template-rows:50px;
grid-template-areas:
"one two";
}
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>test</title>
<link href="style.css" rel="stylesheet">
</head>
<body>
<div class="grid-container-1">
<div class="grid-item-1">This is the line that should show max-content</div>
<div class="grid-item-2">This has a min width of 100px</div>
</div>
</body>
</html>
解决方案
推荐阅读
- reactjs - 在反应原生中保存状态
- c# - 属性或索引器不能分配给它在 C# 中是只读的
- discord.js - 每台服务器运行一个 Discord bot 实例,因此 bot 不会在每台服务器上打开
- android - Kotlin 程序在将 clickListener 设置为在膨胀的 XML 中定义的按钮时抛出 nullPointerException,不知道该去哪里
- angular - 如何使用 RxJS 将我的二维数组重新映射到目标模式?
- r - 如何解决:R CMD检查报告警告和错误
- arrays - 如何使用 matplotlib 为二维数组中的所有(仅 4 种)类型的值绘制图例?
- javascript - React路由器在导入后呈现空白页面
- docker - Docker 写入服务器安装卷,权限问题
- properties - 找不到基本名称 data1 的捆绑包