aboutsummaryrefslogtreecommitdiff
path: root/site/content
diff options
context:
space:
mode:
authorysds <[email protected]>2019-09-03 20:18:44 +0300
committerXhmikosR <[email protected]>2019-10-31 08:30:53 +0200
commitd6ebc60d3d98d48959e6e1bd4eeea4d6e8be4366 (patch)
tree07e19f5afe1e8309588c262ab8242ee11bc61c6a /site/content
parentc62efc3ef69d7dd6e784928b707f52884fab87de (diff)
downloadbootstrap-d6ebc60d3d98d48959e6e1bd4eeea4d6e8be4366.tar.xz
bootstrap-d6ebc60d3d98d48959e6e1bd4eeea4d6e8be4366.zip
Add add and subtract function
Diffstat (limited to 'site/content')
-rw-r--r--site/content/docs/4.3/getting-started/theming.md38
1 files changed, 38 insertions, 0 deletions
diff --git a/site/content/docs/4.3/getting-started/theming.md b/site/content/docs/4.3/getting-started/theming.md
index 46475f2bb..3fd367efd 100644
--- a/site/content/docs/4.3/getting-started/theming.md
+++ b/site/content/docs/4.3/getting-started/theming.md
@@ -215,6 +215,44 @@ You can also specify a base color with our color map functions:
We use the `escape-svg` function to escape the `<`, `>` and `#` characters for SVG background images. These characters need to be escaped to properly render the background images in IE.
+## Add and Subtract function
+
+We use the `add` and `subtract` functions instead of the CSS `calc` function. The primary purpose of these functions is to avoid errors when "unitless" 0 is given to the `calc` expression.
+
+Example where the calc is valid:
+
+{{< highlight scss >}}
+$border-radius: .25rem;
+$border-width: 1px;
+
+.element {
+ // Output calc(.25rem - 1px) is valid
+ border-radius: calc($border-radius - $border-width);
+}
+
+.element {
+ // Output the same calc(.25rem - 1px) as above
+ border-radius: subtract($border-radius, $border-width);
+}
+{{< /highlight >}}
+
+Example where the calc is invalid:
+
+{{< highlight scss >}}
+$border-radius: .25rem;
+$border-width: 0;
+
+.element {
+ // Output calc(.25rem - 0) is invalid
+ border-radius: calc($border-radius - $border-width);
+}
+
+.element {
+ // Output .25rem
+ border-radius: subtract($border-radius, $border-width);
+}
+{{< /highlight >}}
+
## Sass options
Customize Bootstrap 4 with our built-in custom variables file and easily toggle global CSS preferences with new `$enable-*` Sass variables. Override a variable's value and recompile with `npm run test` as needed.