【发布时间】:2019-09-12 21:17:35
【问题描述】:
我很难弄清楚如何将 CSS 编写为 SASS。我已经尝试嵌套代码并使用 & 符号来组合选择器,但我不知道我在做什么。
这是我试图重写为 SASS 的代码
{
margin: 0;
padding: 0;
box-sizing: border-box;
}
ul, li {
list-style-type: none;
}
a {
text-decoration: none;
}
h1, h2, h3, h4, h5, h6 {
font-weight: none;
}
// general
body {
font-family: 'Open Sans', sans-serif;
}
.app {
display: grid;
grid-template-rows: 1fr;
grid-template-columns: 1fr 3fr 5fr;
}
// renders the element off screen so that
// screen readers can still read the text.
.offscreen {
position: absolute;
left: -1000px;
}
// Navigation
.primary-list {
font-family: sans-serif;
background-color: #000;
height: 100vh;
padding-top: 1rem;
padding-bottom: 1rem;
padding-left: 2rem;
}
.primary-list__item {
padding: .5rem;
}
.primary-list__link {
letter-spacing: .05rem;
color: #888;
}
.primary-list__link--active,
.primary-list__link:hover {
color: #FFF;
}
// mail list
.secondary-list {
border-right: 1px solid #CCC;
height: 100vh;
overflow-y: auto;
}
.secondary-list__item {
padding: 2rem;
border-bottom: 1px solid #CCC;
display: flex;
flex-direction: column;
color: #999;
}
.secondary-list__item--active,
.secondary-list__item:hover {
box-shadow: 0px 10px 20px #DDD;
}
.secondary-list__row {
display: flex;
justify-content: space-between;
padding-bottom: 1rem;
}
.secondary-list__title {
color: #000;
font-weight: bold;
}
.secondary-list__aside {
font-style: italic;
}
// mail content
.content {
padding: 2rem;
}
.content__title {
font-size: 4rem;
width: 70%;
margin-bottom: 4rem;
}
.content p {
margin-bottom: 1.5rem;
line-height: 2rem;
}
我想看看这段代码写成 SASS 的样子,也称为 SCSS
【问题讨论】:
-
我已经看到了一些错误。但我想知道您收到什么错误消息;)请编辑您的问题,添加这些错误消息。
-
要求我们建议、查找或推荐书籍、工具、软件库、插件、教程、解释技术或提供任何其他场外资源的问题对于 Stack Overflow Stack 来说是题外话溢出
-
我建议您查看 SASS 的文档,因为您没有向我们展示您编写的任何 SCSS。我还会向您推荐这篇来自 CSS-Tricks 的关于将 SASS 与 BEM 结合使用的优秀文章:css-tricks.com/using-sass-control-scope-bem-naming
-
"SASS also known as SCSS"。 Sass 是预处理器名称,而 SCSS 是两个可用扩展之一。