簡體   English   中英

我不熟悉Sass,我認為main.scss中存在一個小的語法問題,無法編譯

[英]Unfamiliar with Sass, I think there is a small syntax issue in my main.scss keeping me from compiling

我正在設置一個Jekyll頁面,當前使用的主題使用Sass,但是GitHub頁面(我在其中托管)不支持Sass。 因此,我試圖將我的.scss文件轉換為.css,但是此文件出現錯誤:

---
---

@import 'syntax';

$site-background-color: #f5f5f5;
$contrast-color: #333;

$azul-accent-color: #0070bb;
$ruby-accent-color: #e0115f;
$amber-accent-color: #ff7e00;
$avocado-accent-color: #568203;

/*============================================================================*/
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: $site-background-color;
  border-top: 5px solid $contrast-color;
  font-family: 'Source Sans Pro', sans-serif;
  color: $contrast-color;
  font-weight: 400;
  line-height: 1.5;

  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6, p, ul, ol, dl,
blockquote,
table,
img,
hr,
.fluid-width-video-wrapper,
.highlight {
  margin-bottom: 20px;
}

blockquote {
  padding: 0 30px;
  border-left: 2px solid darken($site-background-color, 15%);
}

ul, ol {
  margin-left: 40px;
}

img {
  max-width: 100%;
  height: auto;
  border: none;
  outline: none;
}

a {
  text-decoration: none;
}

hr {
  border : 0;
  height: 25px;
  background : url(/public/images/eagle.png) center center no-repeat;
}

code {
  font-family: Consolas, "Liberation Mono", Courier, monospace;
  font-size: .8rem;
}

p code {
  padding: 0px 5px;
  border: 1px solid #ddd;
  background-color: #f8f8f8;
  border-radius: 3px;
  white-space: nowrap;
}

table {
  border-collapse: collapse;
  border: 1px solid $contrast-color;

  td, th {
    border: 1px solid $contrast-color;
    padding: 5px 10px;
  }

  thead {
    background-color: darken($site-background-color, 10%);
  }
}

// TODO: make dt smaller
dt {
  float: left;
  width: 30%;
  font-weight: bold;
}

dd {
  float: right;
  width: 70%;
}

footer {
  font-size: .8rem;
  text-align: center;
}

/*============================================================================*/
.azul { a { color: $azul-accent-color;
    &:hover { color: darken($azul-accent-color, 20%);
}}}

.ruby { a { color: $ruby-accent-color;
    &:hover { color: darken($ruby-accent-color, 20%);
}}}

.amber { a { color: $amber-accent-color;
    &:hover { color: darken($amber-accent-color, 20%);
}}}

.avocado { a { color: $avocado-accent-color;
    &:hover { color: darken($avocado-accent-color, 20%);
}}}

/*----------------------------------------------------------------------------*/

.highlight {
  padding: 30px;
  border-radius: 6px;
  background-color: #272822;
  color: #f8f8f2;
  line-height: 1;

  code {
    font-size: .7rem;
  }
}

.container {
  max-width: 750px;
  padding: 0 20px;
}

.center {
  text-align: center;
}

.right {
  float: right;
  margin: 0 0 20px 20px;
}

.left {
  float: left;
  margin: 0 20px 20px 0;
}

.top-navbar {
  margin-bottom: 40px;
  height: 110px;

  a {
    display: inline-block;
    color: $contrast-color;
    padding: 66px 20px 25px;
    margin-right: 10px;
    margin-top: -5px;
    text-transform: uppercase;
    border-radius: 0 0 5px 5px;
    border-bottom: 1px solid lighten($contrast-color, 10%);
    transition: all ease-in-out .3s;

    &:hover,
    &.current-page {
      color: $site-background-color;
      border-bottom: none;
    }

    &:hover {
      background-color: $contrast-color;
      transform: translateY(5px);
    }

    &.current-page {
      background-color: $contrast-color;
    }
  }
}

.archive,
.single {
  margin-bottom: 100px;
}

.single {
  font-size: 1.125rem;
  line-height: 28px;
}

.single time {
  color: #999;
  font-size: .9rem;
}

.bundle {
  border-top: 1px solid lighten($contrast-color, 50%);
  padding-top: 10px;
  margin-bottom: 10px;
}

.post-date {
  text-align: right;
}

.not-found {
  margin-top: 150px;
  text-align: center;
  font-size: 2rem;
}

.not-found h1 {
  font-size: 8rem;
}

dl,
.clearfix:before,
.clearfix:after {
    content: " ";
    display: table;
}

dl,
.clearfix:after {
    clear: both;
}

/*============================================================================*/
#logo {
  display: inline-block;
  height: 110px;
  width: 110px;
  background-size: 90px 90px;
  background-position: left center;
  background-repeat: no-repeat;
}

/*============================================================================*/
@media screen and (max-width: 767px) {
  .top-navbar {
    height: 35px;
    text-align: center;
    margin-top: 40px;

    a {
      padding: 5px 10px;
      margin: 5px;
      border-radius: 0;
      border: 1px solid $contrast-color;
      transition: none;

      &:hover {
        transform: none;
      }
    }
  }

  .bundle,
  .post-date {
    text-align: center;
  }

  .bundle article {
    margin-bottom: 30px;
  }

  #logo {
    background-position: center center;
  }
}

錯誤是:

Line 1: Invalid CSS after "-": expected number or function, was "--"

我想象有一個快速解決方案,我根本不熟悉Sass,因此我不具備此解決方案。 我對嗎? 有人知道我該如何解決嗎?

另外,我正在使用以下命令從scss轉換為css sass --watch main.scss:main.css如果有人知道更好的方法,請告訴我!

謝謝你的幫助!

在文件的開頭有兩行--- 您認為他們在做什么? 刪除它們,它們在語法上是無效的,並且正在導致您的錯誤。

Jekyll 2帶來了本地的Sass編譯,實際上,為了使Jekyll編譯Sass文件, 需要使用三行破折號的兩行:

http://jekyllrb.com/docs/assets/

如果您尚未使用Jekyll 2,則當然無法使用。 如果您使用的是Jekyll 2,則可以執行此操作,而不再需要sass --watch命令,Jekyll將自動執行此操作。

您可能遇到了與我相同的問題,即_config.yml不在您的根目錄中。 如果您不想更改文件結構,則可以設置一個新的存儲庫,並將jekyll文件添加到新的gh-pages分支中。 我寫了一個關於它的博客: http : //shinshinwu.github.io/myblog/jekyll/update/2014/12/21/welcome-to-jekyll.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM