Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS Sass Basics Improve Your Workflow with Sass Nested Selectors

Amandeep Pasricha
Amandeep Pasricha
14,932 Points

Unexpected error message please help

Below is my scss code

// VARIABLES ------------------------------------ /

$white: #fff;

$color-primary: #278da4;
$color-secondary: #b13c69;
$color-accent: #eeea72;
$color-shade: #eee;

$color-text: #343434;
$color-bg: #3acec2;
$color-bg-light: #009fe1;

$font-stack-primary: 'Raleway', sans-serif;
$font-stack-secondary: 'Bree Serif', serif;

/* BASE ------------------------------------------- */

* {
  box-sizing: border-box;
}

body {
  color: $color-text;
  font-size: 1rem;
  line-height: 1.5;
  font-family: $font-stack-primary;
  text-align: center;
  margin: 0;
}

h1,
h2 {
  font-family: $font-stack-secondary;
}

ul {
  list-style-type: none;
  padding: 0;
  margin: 0;
}

p {
  margin-bottom: 1.25em;
}

a {
  color: $color-primary;
  text-decoration: none;
  &:hover {
    color: $color-secondary;
   }
}


/* HEADER & FOOTER -------------------------------- */

header {
  height: 460px;
  background: linear-gradient($color-bg-light, $color-bg), url('../img/bg.jpg') no-repeat;
  background-blend-mode: multiply;
  background-size: cover;
  position: relative;
  .main-nav {
  margin-top: 1em;
  li {
    display: inline-block;
    margin: 0 0.65em;
  }
  a {
    color: $white;
    font-size: 0.85em;
    text-decoration: none;
    text-transform: uppercase;
    padding: 0.5em;
  }
}

header::after {
  content: '';
  display: block;
  width: 100%;
  height: 50px; 
  position: absolute;
  transform: skewY(-2deg);
  background-color: $white;
  bottom: -25px;
} 

header h1 {
  color: $white;
  font-size: 4.8em;
  margin-bottom: 0;
  letter-spacing: 1px;
}

header p {
  color: $color-accent;
  font-size: 1.25em;
  margin: 0;
}

footer {
  padding: 2em 0 0;
  height: 100px;
  background-color: $color-shade;
  margin-top: 3.5em;
  position: relative; 
}

footer::before {
  content: '';
  display: block;
  width: 100%;
  height: 50px; 
  position: absolute;
  transform: skewY(-2deg);
  background-color: $color-shade;
  top: -25px;
} 

/* CONTAINERS ------------------------------------- */

.inner {
  padding: 0.5em 1em;
}

.intro {
  margin: auto;
  padding: 1em 1em 3em; 
}

/* COMPONENTS ------------------------------------- */



.img-featured {
  width: 165px;
  border: 4px solid $white; 
  border-radius: 50%;
  margin-top: 75px;
  position: relative;
  z-index: 100;
}

.card {
  display: flex;
  flex-direction: column;
  padding: 1.5em 1em;
  border: 1px solid $color-shade;
  border-radius: 0.25em;
  h1 {
    margin: 0.35em 0 0;
    line-height: 1.25;
  }
  .icon,
  h1{
    color: $color-primary;
  }
}

Here is my css code

/*
Error: Invalid CSS after "}": expected "}", was ""
        on line 218 of scss/style.scss

213:     width: 45%;
214:   }
215: }

Backtrace:
scss/style.scss:218
/usr/lib/ruby/vendor_ruby/sass/scss/parser.rb:1179:in `expected'
/usr/lib/ruby/vendor_ruby/sass/scss/parser.rb:1115:in `expected'
/usr/lib/ruby/vendor_ruby/sass/scss/parser.rb:1110:in `tok!'
/usr/lib/ruby/vendor_ruby/sass/scss/parser.rb:656:in `block'
/usr/lib/ruby/vendor_ruby/sass/scss/parser.rb:647:in `ruleset'
/usr/lib/ruby/vendor_ruby/sass/scss/parser.rb:673:in `block_child'
/usr/lib/ruby/vendor_ruby/sass/scss/parser.rb:666:in `block_contents'
/usr/lib/ruby/vendor_ruby/sass/scss/parser.rb:123:in `stylesheet'
/usr/lib/ruby/vendor_ruby/sass/scss/parser.rb:39:in `parse'
/usr/lib/ruby/vendor_ruby/sass/engine.rb:403:in `_to_tree'
/usr/lib/ruby/vendor_ruby/sass/engine.rb:378:in `_render_with_sourcemap'
/usr/lib/ruby/vendor_ruby/sass/engine.rb:295:in `render_with_sourcemap'
/usr/lib/ruby/vendor_ruby/sass/plugin/compiler.rb:490:in `update_stylesheet'
/usr/lib/ruby/vendor_ruby/sass/plugin/compiler.rb:215:in `block in update_stylesheets'
/usr/lib/ruby/vendor_ruby/sass/plugin/compiler.rb:209:in `each'
/usr/lib/ruby/vendor_ruby/sass/plugin/compiler.rb:209:in `update_stylesheets'
/usr/lib/ruby/vendor_ruby/sass/plugin/compiler.rb:293:in `watch'
/usr/lib/ruby/vendor_ruby/sass/plugin.rb:109:in `method_missing'
/usr/lib/ruby/vendor_ruby/sass/exec/sass_scss.rb:379:in `watch_or_update'
/usr/lib/ruby/vendor_ruby/sass/exec/sass_scss.rb:51:in `process_result'
/usr/lib/ruby/vendor_ruby/sass/exec/base.rb:52:in `parse'
/usr/lib/ruby/vendor_ruby/sass/exec/base.rb:19:in `parse!'
/usr/bin/sass:8:in `<main>'
*/
body:before {
  white-space: pre;
  font-family: monospace;
  content: "Error: Invalid CSS after \"}\": expected \"}\", was \"\"\A         on line 218 of scss/style.scss\A \A 213:     width: 45%;\A 214:   }\A 215: }"; }

I tried to fix the error message on line 215 on the scss file, but I simply can't see what's wrong?? Can anyone see the error? I can't continue with the videos unless I fix this.

2 Answers

Hello

You are missing a closing curly brace on the first header selector

approximately line 77

error

/* HEADER & FOOTER -------------------------------- */

header {
  height: 460px;
  background: linear-gradient($color-bg-light, $color-bg), url('../img/bg.jpg') no-repeat;
  background-blend-mode: multiply;
  background-size: cover;
  position: relative;
  .main-nav {
  margin-top: 1em;
  li {
    display: inline-block;
    margin: 0 0.65em;
  }
  a {
    color: $white;
    font-size: 0.85em;
    text-decoration: none;
    text-transform: uppercase;
    padding: 0.5em;
  }
}

Solution

/* HEADER & FOOTER -------------------------------- */

header {
    height: 460px;
    background: linear-gradient($color-bg-light, $color-bg), url("../img/bg.jpg") no-repeat;
    background-blend-mode: multiply;
    background-size: cover;
    position: relative;
    .main-nav {
        margin-top: 1em;
        li {
            display: inline-block;
            margin: 0 0.65em;
        }
        a {
            color: $white;
            font-size: 0.85em;
            text-decoration: none;
            text-transform: uppercase;
            padding: 0.5em;
        }
    }
}
tomd
tomd
16,701 Points

Looking at your scss I cant see anything that says width: 45%. Are you sure you've included all of your code in this question?