Git Product home page Git Product logo

lab01-get-sassy's Introduction

Let's Get SASS-y

Writing CSS kinda sucks. Many times when writing it, you copy paste code a lot, and there isn't a great way to throw stuff into variables to be reused. An awesome library called SASS fixes all of it!

Installing

  1. For this lab, we will be using macOS to install SASS

If you are using a windows machine, just use a lab machine for this lab since we don't want to wrestle with gem and Ruby installations during the lab

  1. Follow the installation instructions
  2. Confirm that you have sass installed with sass -v
  3. Make sure that you have live-server

What and Why?

Like said above, writing CSS sucks since its way too tedious for its own good. Being able to have variables, import variables, mixins, and whatnot is super helpful. Sass also supports nesting your SCSS code so that its easier to read & encapsulate what and where the styles are being applied.

Getting Started

  1. Begin the live server using live-server --port=4000
  2. Begin the sass watcher using sass --watch sass:css
  3. Open the index.html and sass/styles.css files!
  4. Make a change to h1 to give it the color of red to confirm that the styles are compiling & that the live-server is getting the changes.

Part 1: Variables and Math

  1. Using a nesting structure, select all the ul and ol elements within the .container class and give them the color red.
  2. Now, at the top of the file, declare a variable $red, and assign it the color red.
  3. Now, go back to where you styled the ul adn ol elements. Change that red to $red.
  4. Now, change the value of the $red variable to blue, and see the change take place! ๐Ÿ‘€

Continue making variables & doing nesting selection with these steps:

  1. Make the ul font family be sans-serif and the ol font family be monospace.
  2. Make the background color of paragraphs in the the first container have blue color. In the second container, have those paragraphs be the color orange.
  3. Make the width of container elements have a width of 100% minus 40 pixels.

๐Ÿ’ก Use the calc helper! (google it ๐Ÿ˜‰)

  1. Set the background color of the containers to be pink.

Getting Sassier

Let's get a little more advanced!

Have quite a few color variables at the top that, if you had other SCSS files, you'd want to use there? Make a new sass/colors.scss that defines those color variables and import them into your styles.scss!

Check out how to use mixins and utilize one called sideMargin to set both the left and right margins of the container class. Since the class lacks 40 pixels from the total width, try setting containers to auto -matically center in the page. Try playing with the container width and different values and different values passed into sideMargin.

Syntactic Sugar

Try playing around with the & > ~ Sass operators and see how they work in Sass!

Challenge

Finish early? Figure out how to compile all of your compiled CSS code into a single styles.css file.

lab01-get-sassy's People

Watchers

John Soter avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.