css - 网格区域未被识别
问题描述
我正在尝试制作一个可以在页面上向左或向右调整内容的包装器。我正在使用grid-template-areas
. right_wrapper
但由于某种原因,当我查看网站时,第一个 div被分配为内容而不是空间。关于我做错了什么的任何提示?
这是我我的scss
.contains {
display: grid;
& .left_wrapper {
display:grid;
grid-template-areas: "content space";
grid-template-columns: 6fr 3fr;
& .content {
grid-area: "content";
}
& .space {
grid-area: "space";
}
}
& .right_wrapper {
display:grid;
grid-template-areas: "space content";
grid-template-columns: 3fr 6fr;
& .content {
grid-area: "content";
}
& .space {
grid-area: "space";
}
}
}
这是HTML
<div></div>
<div class="right_wrapper">
<div class="content">
<h2>Right Headline</h2>
<p>Placeholder text is useful when you need to see what a page design looks like, but the actual content
isn't available.</p>
<p>It's like having someone with identical measurements check the fit of a dress before trying it on
yourself.</p>
<p>This text is going to be replaced once the website is completed. You are currently reading text that
is
written in English, not any other language. We aren't quite sure what to put here yet.</p>
</div>
<div class="space"></div>
</div>
<div></div>
解决方案
您不使用引号来定义网格区域。
无效的: grid-area: "content"
有效的: grid-area: content
标识符不能被引用;否则它们将被解释为字符串。(以下来源)
来自 CSS 网格规范:
§ 3.2。作者定义的标识符:
<custom-ident>
类型一些属性接受任意作者定义的标识符作为组件值。这种通用数据类型由 表示
<custom-ident>
,并表示任何不会被误解为该属性值定义中的预定义关键字的有效 CSS 标识符。此类标识符完全区分大小写,即使在 ASCII 范围内也是如此(例如,示例和示例是两个不同的、不相关的用户定义标识符)。
从 CSS 值和单位规范:
CSS 标识符,一般用 表示
<ident>
,由符合<ident-token>
语法的字符序列组成。标识符不能被引用;否则它们将被解释为字符串。
推荐阅读
- node.js - 如何将 Multer S3 流传递给另一个函数
- macos - Applescript 将 Mac 显示分辨率更改为“缩放”、“更大的文本”
- java - 如何对集合子集应用进一步的过滤器
- cakephp - CakePHP 中的自动清除消息
- nativescript - 如何在 NativeScript 中对 .udsz 文件使用 AR QuickLook?
- node.js - 如何解决 socket.io-client 连接到服务器的问题?
- python - 没有在python中正确解析嵌套的xml标签
- javascript - 如何在 JavaScript 中传递引用?
- android - Firestore:在事务中检查 NotNull 并阻止调用 OnSuccessful 回调
- python - 如何使用openpyxl将['apple','carrots','mango']等列表导出到excel的一列中?在 Python 中