Menu

[r7]: / docs / constants.html  Maximize  Restore  History

Download this file

55 lines (54 with data), 2.5 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Constants: Switch</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<link type="text/css" rel="stylesheet" title="Default Stylesheet" href="global.css" />
</head>
<body id="constants" class="documentation">
<div id="header">
</div>
<div id="localNav">
<h2>Switch</h2>
<ul id="extensionsNav">
<li><a href="install_mac.html">Installation (Mac)</a></li>
<li><a href="install_windows.html">Installation (Windows)</a></li>
<li><a href="variables.html">Variables</a></li>
<li><a href="constants.html">Constants</a></li>
<li><a href="includes.html">Includes</a></li>
<li><a href="comments.html">Comments</a></li>
<li><a href="ignore.html">Ignore</a>
<li><a href="auto_prepending.html">Automatic Selector Prepending</a></li>
<li><a href="inheritance.html">Inheritance</a></li>
<li><a href="copy.html">Property Duplication</a></li>
<li><a href="property_lookup.html">Property Look-ups</a></li>
</ul>
</div>
<div id="mainContent">
<h2>Constants: <code>@constant</code></h2>
<p>Allows authors to define a one or more values that cannot be changed while the stylesheet is parsed. Unlike variables, constants do not have to begin with a dollar-sign ($). Also unlike variables, constants have no scope, they are considered global and can be used anywhere.</p>
<div class="example">
<pre class="input"><code>@constant BODY_BACKGROUND_COLOR: #fff;
.container {
background-color: BODY_BACKGROUND_COLOR;
}
</code></pre>
<pre class="output"><code>.container {
background-color: #fff;
}</code></pre>
</div>
<p>For clarity, authors should define constants with names in all-caps. While constants do not have to begin with $, authors may wish to do so as some constant names can cause unexpected results!</p>
<div class="example">
<pre class="input"><code>@constant 1px: 10em;
.unexpected {
border: 1px solid #f00;
}
</code></pre>
<pre class="output"><code>.unexpected {
border: 10em solid #f00;
}</code></pre>
</div>
<p>If a constant is declared again or an attempt is made to give it a different value, the parser will ignore the request and continue processing the stylesheet. However, a parser may add a comment to the stylesheet or provide another indication that a invalid request was made.</p>
</div>
</body>
</html>
MongoDB Logo MongoDB