$num: 33.33333333%; .hero { width: ceil($num); }
Question 1/15
Question 2/15
Question 3/15
.hero { width: percentage(2 / 3); }
Question 4/15
Question 5/15
Question 6/15
Question 7/15
Question 8/15
Question 9/15
Question 10/15
Question 11/15
Question 12/15
Question 13/15
Question 14/15
Question 15/15
Your Answers
Question 1/15
$num: 33.33333333%; .hero { width: ceil($num); }
In Sass, the ceil() function is used to round a number up to the nearest integer. This function takes a single argument, which can be a number or a value that can be converted to a number, and returns the nearest integer that is greater than or equal to the argument value.
Question 2/15
The round() function is used to round a number to the nearest whole number in Sass. Here is an example code:
font-size: round(16.8px);
Question 3/15
.hero { width: percentage(2 / 3); }
In Sass, the percentage() function is used to convert a decimal number into a percentage value. This function takes a single argument, which can be a number or a value that can be converted to a number, and returns the percentage value of that number as a string.
Question 4/15
Sass is an acronym for Syntactically Awesome Style Sheets. It is a CSS preprocessor that extends the capabilities of CSS with variables, functions, and nesting.
Question 5/15
Sass placeholders are selectors that are defined using the % symbol, and can be extended using the @extend directive. Placeholders are useful for creating reusable sets of styles that are not meant to be rendered as standalone selectors.
Here's an example of a Sass placeholder selector:
%button { display: inline-block; padding: 10px 20px; background-color: #3498db; color: #fff; border: none; border-radius: 4px; } .btn-primary { @extend %button; } .btn-secondary { @extend %button; background-color: #e67e22; }
In this example, the %button selector is defined as a placeholder selector using the % symbol. The styles defined within the %button selector will not be output in the compiled CSS, but can be extended by other selectors using the @extend directive.
The .btn-primary selector extends the %button selector using @extend, inheriting all of the styles defined within %button. The .btn-secondary selector also extends %button, but overrides the background-color property to create a different button style. The resulting compiled CSS will be:
.btn-primary, .btn-secondary { display: inline-block; padding: 10px 20px; background-color: #3498db; color: #fff; border: none; border-radius: 4px; } .btn-secondary { background-color: #e67e22; }
Question 6/15
Sass variables are defined using the $ symbol, followed by the variable name and the value. Here is an example code:
$primary-color: #ff0000;
Question 7/15
The file extension most commonly used for Sass files is .scss, which stands for "Sassy CSS". Sass also supports .sass file extensions, which is the original syntax used for Sass.
Question 8/15
The sass command is used to compile Sass files into CSS. Here is an example code:
sass input.scss output.css
Question 9/15
Sass mixins allow you to define a block of reusable code that can be included in different parts of your Sass code. Here is an example code:
@mixin center { display: flex; justify-content: center; align-items: center; }
You can then include the mixin in your code by using the @include directive, followed by the name of the mixin:
.container { @include center; }
When the Sass is compiled to CSS, the output will contain the CSS rules defined in the mixin:
.container { display: flex; justify-content: center; align-items: center; }
Question 10/15
The Sass operator used to concatenate strings is the plus (+) operator. The plus operator is used to combine two or more strings into a single string. When the plus operator is used with a string and a variable, it will convert the variable value to a string and concatenate it with the original string. Here is an example code:
$font-family: "Helvetica"; $font-size: 16px; h1 { font: $font-size + " " + $font-family; }
In this example, the plus operator is used to concatenate the $font-size variable, a space character, and the $font-family variable into a single string that is applied as the value for the font property of the h1 element. The resulting CSS output will be:
h1 { font: 16px Helvetica; }
Question 11/15
The @import directive is used to import external Sass files into your Sass code. Here is an example code:
@import "variables.scss";
Question 12/15
Sass functions are a set of built-in functions that allow you to perform calculations and manipulate values in your Sass code. Sass functions are called by passing arguments enclosed in parentheses, and can be used in combination with variables to create more dynamic and flexible stylesheets. Some of the commonly used Sass functions include color manipulation functions (such as lighten() and darken()), unit conversion functions (such as px-to-em() and em-to-rem()), and string manipulation functions (such as str-length() and str-index()).
Here is an example code for using the lighten() function to manipulate a color value:
$primary-color: #3498db; nav { background-color: lighten($primary-color, 10%); }
In this example, the lighten() function is used to increase the lightness of the $primary-color variable by 10%, and the resulting color value is applied as the background-color for the nav element.
Question 13/15
There are multiple ways to write comments in Sass:
// This comment won't be included in the CSS. /* But this comment will, except in compressed mode. */ /* It can also contain interpolation: * 1 + 1 = #{1 + 1} */ /*! This comment will be included even in compressed mode. */
Question 14/15
Sass provides a set of control directives that allow you to create loops and conditional statements in your Sass code. The @for directive is used to create a loop that iterates a specified number of times.
Question 15/15
Sass provides a set of control directives that allow you to create conditional statements and loops in your Sass code. Here is an example code:
@if $background-color == #fff { body { color: #000; } }