- Sass 教程
- Sass - 首頁
- Sass - 概述
- Sass - 安裝
- Sass - 語法
- 使用 Sass
- Sass - CSS 擴充套件
- Sass - 註釋
- Sass - 指令碼
- Sass - @ 規則和指令
- 控制指令和表示式
- Sass - Mixin 指令
- Sass - 函式指令
- Sass - 輸出樣式
- 擴充套件 Sass
- Sass 有用資源
- Sass - 面試問題
- Sass - 快速指南
- Sass - 有用資源
- Sass - 討論
Sass - 括號
介紹
括號是一對符號,通常用圓括號( )或方括號 [ ] 標記,提供影響運算順序的符號邏輯。
示例
以下示例演示了在 SCSS 檔案中使用括號 −
<html>
<head>
<title>String Operations</title>
<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:\ruby\lib\sass\style.scss:style.css
接下來,執行上述命令;它將自動建立帶有以下程式碼的 style.css 檔案 −
style.css
p {
font-size: 17px;
color: #ff0000;
}
輸出
讓我們執行以下步驟,瞭解以上給定程式碼是如何工作的 −
將上述給定的 html 程式碼儲存到 parentheses_example.html 檔案中。
在瀏覽器中開啟此 HTML 檔案,輸出如下所示。
sass_script.htm
廣告