括弧是對其通過圓括號()或方括號[],它提供符號邏輯影響操作的順序,通常都標示了標誌。
示例
下麵的例子演示了SCSS檔中使用括弧:
<html> <head> <title>字串操作符 - www.xuhuhu.com</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link rel="stylesheet" type="text/css" href="style.css" /> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h2>Example using Sass Parentheses</h2> <p>SASS stands for Syntactically Awesome Stylesheet..</p> </div> </body> </html>
接下來創建了一個檔:style.scss.
style.scss
p { font-size: 5px + (6px * 2); color:#ff0000; }
可以告訴SASS監視檔,並隨時使用下麵的命令更新SASS檔修改CSS:
sass --watch C:\Ruby22-x64\style.scss:style.css
接著執行上面的命令,它會自動創建style.css檔,下麵的代碼:
style.css
p { font-size: 17px; color: #ff0000; }
執行輸出
讓我們來執行以下步驟,看看上面的代碼工作:
-
保存上述的HTML代碼到parentheses_example.html檔。
-
在流覽器中打開該HTML檔,輸出如下得到顯示。