Day #2 of learning & posting
Day #2 on my sass project

Day #2 of learning & posting

Today I learned about pseudo classes & calc() in sass --

Sass allows you to work with pseudo-classes just like you would in regular CSS. You can use pseudo-classes in Sass to apply styles to elements that meet specific conditions. Here's an explanation of how you can use pseudo-classes in Sass:

Child and Sibling Pseudo-classes: You can also use pseudo-classes like :first-child, :last-child, :nth-child(), :nth-of-type(), and so on to target specific child or sibling elements.

li:first-child {
  font-weight: bold;
}        
This code will make the first list item within its parent element bold.

In Sass, the calc() function is used to perform mathematical calculations within CSS property values. It allows you to perform arithmetic operations like addition, subtraction, multiplication, and division, which can be useful when setting dynamic values for CSS properties. The calc() function in Sass works similarly to how it works in regular CSS.

Here's how you can use the calc() function in Sass:

In this example:

  1. We define a variable $sidebar-width with a value of 250px.
  2. We use the calc() function to calculate the value of $content-width by subtracting $sidebar-width from 100%. The #{$variable} syntax is used to interpolate the variable's value within the calc() function.
  3. We then use these calculated values to set the width of the .sidebar and .content elements.

$sidebar-width: 250px;
$content-width: 100% - #{$sidebar-width};

.sidebar {
  width: $sidebar-width;
}

.content {
  width: $content-width;
}        


To view or add a comment, sign in

More articles by Pratik Kumar Jaiswal

  • Day 25 Learning In Public

    Day 25: Explored the power of React Query and utilized Tanstack to optimize data fetching and state management in React…

    1 Comment
  • Day 23 :Learning In Public

    "Unlocking React's Potential: A Deep Dive into the Callback Hook" Mastered the Callback Hook in React today, a powerful…

    1 Comment
  • Day #17 of Learning in Public

    In today's project, I unveiled "Marvel Assemble," a dynamic carousel webpage born from HTML, CSS, and JavaScript…

  • DAY #16 of Learning In Public

    Today's creative Endeavor resulted in : A tranquil meditation page crafted with HTML, CSS, and JavaScript. The soothing…

  • DAY #14 OF LEARNING IN PUBLIC

    Affordigo Day 14: Explored the CSS property, a pivotal tool in creating versatile, multi-line layouts within flex…

  • Day #13 of Learning In Public

    Day 13: Today's exploration led me to the intriguing realm of the CSS property. Discovering how to modify and animate…

    2 Comments
  • Day 12: Today, I delved into the fundamentals of setting up a project.

    Learning the essentials of project structuring, media queries, and responsive design principles has been pivotal. It's…

    2 Comments
  • Save your preloader spinner

    codepen link provided below Loader Spinner Follow me Pratik Kumar Jaiswal for more!!! 📈 🚀#html #css #javascript…

  • Day #10 of Learning In Public

    Day 10: Diving into the world of Sass, I harnessed the versatility of , , and properties to create dynamic layouts…

  • Day #9 of Learning in Public.

    A productive day exploring the power of in CSS for layering elements and mastering linear hover effects. These skills…

    1 Comment

Insights from the community

Others also viewed

Explore topics