【问题标题】:SASS code problemsSASS 代码问题
【发布时间】:2017-01-08 07:08:40
【问题描述】:

我一直在尝试学习 flexbox,但我在移动设备上弄乱了我的 codepen,发生了一些事情,我无法确定问题所在,但它一直给我一个错误,我终生无法发现它!一切似乎都很好。

代码并不令人惊奇,我还不是很擅长编码,它不是 DRY,它很乱,不是很可读,但它正在工作。即使出现错误,该页面也可以正常工作。现在它什么都不做,甚至不会加载。

CSS 编辑器出现错误,我无法修复!

请帮帮我,这真的让我很烦,我已经看了好几个小时来改变事情。

这里是代码笔:http://codepen.io/joecox91/pen/GrJXQX

抱歉,我不记得如何将 codepen 嵌入问题中!

    @import url('https://fonts.googleapis.com/css?family=Roboto+Mono:300,400');

* {
  padding:0;
  margin:0;
  text-decoration:none;
  box-sizing:border-box;
}
body, html {
  padding:0;
  margin:0;
  width:100%;
  height:100%;
}

header {
  background:#ffffff;
  border-bottom:1px solid #cccccc;
}

/* flex-flow: flex-direction flex-wrap */

.container {
  display:-webkit-flex;
  display:flex;
  justify-content:center;
  flex-flow: row wrap;
}

/* flex:flex-grow flex-shrink flex-basis */

.container section {
  height:auto;
  flex-grow:1;
  padding:20px 0;
  flex-shrink:1;
  flex-wrap:wrap;
}

.two {
  align-content:space-around;
  margin:40px 20px;
  font-family: 'Roboto Mono', monospace;
}



#content {
  padding:20px;
  width:60%;
}

#sidebar {
  background:black;
  width:20%;
}

// .container section:nth-child(2n) {
//   background:black;
// }

#header {
  display: flex;
  height:100%;
  align-items:center;
  justify-content: center;
  flex-flow:column wrap;
  font-family:helvetica;

  h1 {
    font-size:2em;
    letter-spacing:1.5px;
  }

  h2 {
    font-size:1.2em;
  }
}

#nav {
  display:flex;
  justify-content:center;
  align-items:center;
  a {
    padding:20px;
    color:#aaaaaa;
    font-family:helvetica;
    font-size:14px;
    margin-right:1px;
    text-transform:uppercase;
    border-bottom:2px solid white;
    transition:0.2s ease-out;

    &.active {
      border-bottom:2px solid black;
      color:black;
    }

    &:last-child {
      margin-right:0;
      margin-left:20px;
      border:1px solid #aaaaaa;
      border-radius:5px;

      &.active {
        border:1px solid black;
      }
    }

    &:hover {
      color:black;
      transition:0.2s ease-out;

      &:last-child {
        border:1px solid black;
      }
    }
  }


}

.spin1 {
        position:relative;
  animation:menutate 1.5s infinite;
animation-timing-function: linear;
        top:-1px;
         left:10px;
        width:1px;
  border-top:5px solid rgba(0,0,0,0);
  border-right:5px solid white;
  border-left:5px solid white;
  border-bottom:5px solid rgba(0,0,0,0);

        background:black;
      }

#mobile-menu {
  display:none;
}

#mobile-header {
}

@keyframes menutate {
  0% {
    transform:rotate(0);
  }

  100% {
    transform:rotate(360deg);
  }
}


#navi {
  display:none;
}


  @media screen and (max-width:720px) {

    .container,
    .two, {
    flex-flow:column wrap;
    }

    #content {
      width:100%;
    }

    #sidebar {
      width:100%;
    }

    #navi {
      position:absolute;
      display:block;
      height:100%;
      top:0;
      left:0;
      background:deepskyblue;
      width:80%;
      transform:translate(-100%);
      z-index:10000;
    }

    #navi.extend {
      box-shadow:0px 0px 10px 10px rgba(0,0,0,0.4);
    }

    #header {
      justify-content:flex-end;
      align-items:flex-end;
      padding-right:20px;

      h1 {
        padding:0;
        margin:0;
      }
    }

    #nav {
      display:none;
    }

    .mobile-hide {
      display:none;
    }

    body {
      position:relative;
      transform:translate(0);
      transition:0.3s ease-out;
    }


    body.extend {
      transform:translateX(80%);
      transition:0.3s ease-out;
    }

    #mobile-menu {
      position:fixed;
      top:22px;
      left:20px;
      display:block;
      height:50px;
      overflow:none;
      width:50px;
      padding:8px;
      z-index:500000;
      transition:0.2s ease;
      filter: opacity(1);

      &.extend {
        transform:translateX(-180%);
        transition:0.4s ease;
      }

      &:hover {
        cursor:pointer;
        transition:0.5s ease;
        filter:opacity(0.6);
      }

      span {
        position:absolute;
        height:4px;
        background:black;
        width:40px;
        text-align:center;
        transition:0.5s ease;

        &.menu-animate {
          transition:0.5s ease;
        }

      &:hover {
        cursor:pointer;
      }

        &:last-child {
          border:none;
          font-size:12px;
          background:none;
          height:auto;
          width:40px;
          top:38px;
          text-align:center;
        }
       
        &:nth-child(1) {
          top:8px;

          &.menu-animate {
            top:13px;
            transform:rotate(45deg);
          }
        }

        &:nth-child(2) {
          top:18px;

           &.menu-animate {
             top:13px;
            transform:rotate(-45deg);
          }
        }

        &:nth-child(3) {
          top:28px;
             &.menu-animate {
            top:13px;
            filter:opacity(0);
          }
        }
      }

    
  }
  
}

有 SASS 或半 SASS。我遇到的问题是:

Invalid CSS after "... position:fixed": expected "{", was ";"

这对我来说毫无意义!为什么它会在任何地方期待一个开放的大括号?在 position:fixed... 之后是怎么回事?

发送帮助!

谢谢

【问题讨论】:

    标签: css sass


    【解决方案1】:

    问题是你的 SCSS 的几行中有一些奇怪的间距字符 - 这让 Sass 绊倒了。如果你用适当的空格替换那些东西似乎工作:

    @import url('https://fonts.googleapis.com/css?family=Roboto+Mono:300,400');
    
    * {
      padding:0;
      margin:0;
      text-decoration:none;
      box-sizing:border-box;
    }
    body, html {
      padding:0;
      margin:0;
      width:100%;
      height:100%;
    }
    
    header {
      background:#ffffff;
      border-bottom:1px solid #cccccc;
    }
    
    /* flex-flow: flex-direction flex-wrap */
    
    .container {
      display:-webkit-flex;
      display:flex;
      justify-content:center;
      flex-flow: row wrap;
    }
    
    /* flex:flex-grow flex-shrink flex-basis */
    
    .container section {
      height:auto;
      flex-grow:1;
      padding:20px 0;
      flex-shrink:1;
      flex-wrap:wrap;
    }
    
    .two {
      align-content:space-around;
      margin:40px 20px;
      font-family: 'Roboto Mono', monospace;
    }
    
    
    
    #content {
      padding:20px;
      width:60%;
    }
    
    #sidebar {
      background:black;
      width:20%;
    }
    
    // .container section:nth-child(2n) {
    //   background:black;
    // }
    
    #header {
      display: flex;
      height:100%;
      align-items:center;
      justify-content: center;
      flex-flow:column wrap;
      font-family:helvetica;
    
      h1 {
        font-size:2em;
        letter-spacing:1.5px;
      }
    
      h2 {
        font-size:1.2em;
      }
    }
    
    #nav {
      display:flex;
      justify-content:center;
      align-items:center;
      a {
        padding:20px;
        color:#aaaaaa;
        font-family:helvetica;
        font-size:14px;
        margin-right:1px;
        text-transform:uppercase;
        border-bottom:2px solid white;
        transition:0.2s ease-out;
    
        &.active {
          border-bottom:2px solid black;
          color:black;
        }
    
        &:last-child {
          margin-right:0;
          margin-left:20px;
          border:1px solid #aaaaaa;
          border-radius:5px;
    
          &.active {
            border:1px solid black;
          }
        }
    
        &:hover {
          color:black;
          transition:0.2s ease-out;
    
          &:last-child {
            border:1px solid black;
          }
        }
      }
    
    
    }
    
    .spin1 {
            position:relative;
      animation:menutate 1.5s infinite;
    animation-timing-function: linear;
            top:-1px;
             left:10px;
            width:1px;
      border-top:5px solid rgba(0,0,0,0);
      border-right:5px solid white;
      border-left:5px solid white;
      border-bottom:5px solid rgba(0,0,0,0);
    
            background:black;
          }
    
    #mobile-menu {
      display:none;
    }
    
    #mobile-header {
    }
    
    @keyframes menutate {
      0% {
        transform:rotate(0);
      }
    
      100% {
        transform:rotate(360deg);
      }
    }
    
    
    #navi {
      display:none;
    }
    
    
      @media screen and (max-width:720px) {
    
        .container,
        .two, {
        flex-flow:column wrap;
        }
    
        #content {
          width:100%;
        }
    
        #sidebar {
          width:100%;
        }
    
        #navi {
          position:absolute;
          display:block;
          height:100%;
          top:0;
          left:0;
          background:deepskyblue;
          width:80%;
          transform:translate(-100%);
          z-index:10000;
        }
    
        #navi.extend {
          box-shadow:0px 0px 10px 10px rgba(0,0,0,0.4);
        }
    
        #header {
          justify-content:flex-end;
          align-items:flex-end;
          padding-right:20px;
    
          h1 {
            padding:0;
            margin:0;
          }
        }
    
        #nav {
          display:none;
        }
    
        .mobile-hide {
          display:none;
        }
    
        body {
          position:relative;
          transform:translate(0);
          transition:0.3s ease-out;
        }
    
    
        body.extend {
          transform:translateX(80%);
          transition:0.3s ease-out;
        }
    
        #mobile-menu {
          position:fixed;
          top:22px;
          left:20px;
          display:block;
          height:50px;
          overflow:none;
          width:50px;
          padding:8px;
          z-index:500000;
          transition:0.2s ease;
          filter: opacity(1);
    
          &.extend {
            transform:translateX(-180%);
            transition:0.4s ease;
          }
    
          &:hover {
            cursor:pointer;
            transition:0.5s ease;
            filter:opacity(0.6);
          }
    
          span {
            position:absolute;
            height:4px;
            background:black;
            width:40px;
            text-align:center;
            transition:0.5s ease;
    
            &.menu-animate {
              transition:0.5s ease;
            }
    
          &:hover {
            cursor:pointer;
          }
    
            &:last-child {
              border:none;
              font-size:12px;
              background:none;
              height:auto;
              width:40px;
              top:38px;
              text-align:center;
            }
    
            &:nth-child(1) {
              top:8px;
    
              &.menu-animate {
                top:13px;
                transform:rotate(45deg);
              }
            }
    
            &:nth-child(2) {
              top:18px;
    
               &.menu-animate {
                 top:13px;
                transform:rotate(-45deg);
              }
            }
    
            &:nth-child(3) {
              top:28px;
                 &.menu-animate {
                top:13px;
                filter:opacity(0);
              }
            }
          }
      }
    }
    

    Here's 带有修复程序的 Codepen。

    我建议使用打开“显示不可见”的编辑器,以便您可以轻松查看此类问题。

    【讨论】:

    • 啊,太棒了,非常感谢。当我厌倦了在手机上编辑时,一定会发生这种情况。输入键正在做各种奇怪的事情:(谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-10
    • 2012-04-11
    • 2021-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-21
    相关资源
    最近更新 更多