Define Root Colors Variables and Set up Box-Sizing for a CSS Layout

Share this video with your friends

Social Share Links

Send Tweet
Published 4 years ago
Updated 4 years ago

We will discuss the necessary CSS styles that we will need to start using CSS Grid. First, you'll download an index.html file and style.css from this GitHub repo - lesson1 folder.

This will contain some set up that will help you get up and running quickly. We'll discuss how to set and use CSS variables as well as box-sizing. box-sizing allows you to add border and padding without increasing the box-size, important for CSS grid!

Instructor: [0:00] Go to the GitHub repo linked in this lesson and download style.css and index.html starter files from lesson one folder. The style.css file has basic styling, like root colors, background color, and the header styling.

[0:14] The root colors allow you to set a name for specific colors. As you can see, I've set gray to be DADEDF. When I call the color gray in the style.css, as I did here using var, it will call DADEDF instead of a generic gray.

[0:31] Box-sizing border-box allows you to add borders and padding to boxes without increasing the box size. If you try to make things fit somewhere or wondered how you can stop boxes from bleeding out of the screen, you probably know what issue this would address.

[0:46] Here, we'll inherit the box-sizing from the HTML class. Making sure these two box-sizing lines are present will make your CSS grid life much easier.

[0:55] Now we have a preview for the lesson, it's worth noting that there is nothing currently showing up because there is no content in the index.html. We have the styling with the CSS, but nothing will be showing up.

egghead
egghead

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today