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! While you're at it, check out some resources Treehouse students have shared here.

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 workflow question with variables

I know the saying of TIMTOWTDI, but just wanted to get the experience from some Sass users.

I've created a variable called $fullwidth: 100%; and in some width properties, we have 60%, 30%, etc. as you can imagine. My question is would you rather use:

width: 30%; or width: $fullwidth - 70%;

Are there any reasons why one way would be preferred over the other? Or even a third way that would be better? Thanks!

1 Answer

In my opinion the best way to do it is the best way that suits your developing logic. I would do

$fullwidth: 100%; .container{ width: 30%; }

The reason I wouldn't subtract from $fullwidth is because you're not gaining anything by using the variable in this instance. When it comes down to this the only answer should be logic. Apply what makes sense, and don't feel like you have to use a variable where it isn't necessary just because you can.

Hope this helps.