mirror of
https://github.com/danog/sass-site.git
synced 2024-12-11 08:59:51 +01:00
8e97e71e66
* Fix invalid semicolon on SASS example * Fix wrong argument reference * Fix invalid assignment to variable due to scope
74 lines
1.8 KiB
Plaintext
74 lines
1.8 KiB
Plaintext
---
|
|
title: "null"
|
|
introduction: >
|
|
The value `null` is the only value of its type. It represents the absence of a
|
|
value, and is often returned by [functions](../at-rules/function) to indicate
|
|
the lack of a result.
|
|
---
|
|
|
|
<% example(autogen_css: false) do %>
|
|
@use "sass:map";
|
|
@use "sass:string";
|
|
|
|
@debug string.index("Helvetica Neue", "Roboto"); // null
|
|
@debug map.get(("large": 20px), "small"); // null
|
|
@debug &; // null
|
|
===
|
|
@use "sass:map"
|
|
@use "sass:string"
|
|
|
|
@debug string.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()`]: ../modules#if
|
|
|
|
<%= partial 'code-snippets/example-if-parent-selector' %>
|