sass-site/source/documentation/operators/relational.html.md.erb

54 lines
1.5 KiB
Plaintext
Raw Normal View History

2018-09-01 22:35:20 +02:00
---
title: Relational Operators
2019-03-05 01:24:31 +01:00
introduction: >
Relational operators determine whether [numbers](../values/numbers) are larger
or smaller than one another. They automatically convert between compatible
units.
2018-09-01 22:35:20 +02:00
---
* `<expression> < <expression>` returns whether the first [expression][]'s value
is less than the second's.
* `<expression> <= <expression>` returns whether the first [expression][]'s
value is less than or equal to the second's.
* `<expression> > <expression>` returns whether the first [expression][]'s value
is greater than to the second's.
* `<expression> >= <expression>`, returns whether the first [expression][]'s
value is greater than or equal to the second's.
[expression]: ../syntax/structure#expressions
<% example(autogen_css: false) do %>
@debug 100 > 50; // true
@debug 10px < 17px; // true
@debug 96px >= 1in; // true
@debug 1000ms <= 1s; // true
===
@debug 100 > 50 // true
@debug 10px < 17px // true
@debug 96px >= 1in // true
@debug 1000ms <= 1s // true
2018-09-01 22:35:20 +02:00
<% end %>
Unitless numbers can be compared with any number. They're automatically
converted to that number's unit.
<% example(autogen_css: false) do %>
@debug 100 > 50px; // true
@debug 10px < 17; // true
===
@debug 100 > 50px // true
@debug 10px < 17 // true
2018-09-01 22:35:20 +02:00
<% end %>
Numbers with incompatible units can't be compared.
<% example(autogen_css: false) do %>
@debug 100px > 10s;
// ^^^^^^^^^^^
// Error: Incompatible units px and s.
===
@debug 100px > 10s
// ^^^^^^^^^^^
// Error: Incompatible units px and s.
2018-09-01 22:35:20 +02:00
<% end %>