Skip to main content

Calculating Values Using Operations

  • Chapter
  • First Online:
  • 548 Accesses

Abstract

When writing CSS, we frequently create static rules for similar elements - while this works, it is certainly not the most efficient way of writing code! What if we could take it up a notch, and use maths to create our values dynamically?

Yes, you heard correctly: using maths! Before you run for the hills, this isn’t as crazy as it may seem - rather than have to manually work out the sizes of elements in a responsive layout, for example, we can instead use simple operators in Sass to work this out for us automatically. This is just one way of using basic maths in Sass, which makes it a really powerful tool - over the course of this chapter, we’ll work through some simple examples of maths that can really help save you time when it comes to developing in Sass.

This is a preview of subscription content, log in via an institution.

Buying options

eBook
USD   19.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   29.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2019 Alex Libby

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Libby, A. (2019). Calculating Values Using Operations. In: Introducing Dart Sass. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-4372-5_4

Download citation

Publish with us

Policies and ethics