mirror of
https://github.com/danog/sass-site.git
synced 2024-12-04 10:28:22 +01:00
69 lines
1.6 KiB
Plaintext
69 lines
1.6 KiB
Plaintext
---
|
|
title: null
|
|
---
|
|
|
|
The value `null` is the only value of its type. It represents the absence of a
|
|
value, and is often returned by [functions][] to indicate the lack of a result.
|
|
|
|
[functions]: ../at-rules/function
|
|
|
|
<% example(autogen_css: false) do %>
|
|
@debug str-index("Helvetica Neue", "Roboto"); // null
|
|
@debug map-get(("large": 20px), "small"); // null
|
|
@debug &; // null
|
|
===
|
|
@debug str-index("Helvetica Neue", "Roboto") // null
|
|
@debug map-get(("large": 20px), "small") // null
|
|
@debug & // null
|
|
<% end %>
|
|
|
|
If a [list][] contains a `null`, that `null` is omitted from the generated CSS.
|
|
|
|
[list]: lists
|
|
|
|
<% example do %>
|
|
$fonts: ("serif": "Helvetica Neue", "monospace": "Consolas");
|
|
|
|
h3 {
|
|
font: 18px bold map-get($fonts, "sans");
|
|
}
|
|
===
|
|
$fonts: ("serif": "Helvetica Neue", "monospace": "Consolas")
|
|
|
|
h3
|
|
font: 18px bold map-get($fonts, "sans")
|
|
<% end %>
|
|
|
|
If a property value is `null`, that property is omitted entirely.
|
|
|
|
<% example do %>
|
|
$fonts: ("serif": "Helvetica Neue", "monospace": "Consolas");
|
|
|
|
h3 {
|
|
font: {
|
|
size: 18px;
|
|
weight: bold;
|
|
family: map-get($fonts, "sans");
|
|
}
|
|
}
|
|
===
|
|
$fonts: ("serif": "Helvetica Neue", "monospace": "Consolas")
|
|
|
|
h3
|
|
font:
|
|
size: 18px
|
|
weight: bold
|
|
family: map-get($fonts, "sans")
|
|
<% end %>
|
|
|
|
`null` is also [*falsey*][], which means it counts as `false` for any rules or
|
|
[operators][] that take booleans. This makes it easy to use values that can be
|
|
`null` as conditions for [`@if`][] and [`if()`][].
|
|
|
|
[*falsey*]: ../at-rules/control/if#truthiness-and-falsiness
|
|
[operators]: ../operators/boolean
|
|
[`@if`]: ../at-rules/control/if
|
|
[`if()`]: ../functions#if
|
|
|
|
<%= partial 'code-snippets/example-if-parent-selector' %>
|