calc()函數是CSS中的內置函數,用於基於CSS屬性執行計算。
用法:
calc( Expression )
參數:此函數接受強製的單個參數Expression。該參數包含需要實現的數學表達式。此參數使用的運算符為:+,-,*,/
以下示例程序旨在說明CSS中的calc()函數:
程序:
<!DOCTYPE html>
<html>
<head>
<title>calc function</title>
<style>
.geeks {
position:absolute;
left:50px;
width:calc(100% - 20%);
height:calc(500px - 300px);
background-color:green;
padding-top:30px;
text-align:center;
}
.gfg {
font-size:40px;
font-weight:bold;
color:white
}
h1 {
color:white;
}
</style>
</head>
<body>
<div class = "geeks">
<div class = "gfg">GeeksforGeeks</div>
<h1>The calc() Function</h1>
</div>
</body>
</html>
輸出:
相關用法
- PHP Ds\Map put()用法及代碼示例
- d3.js d3.lab()用法及代碼示例
- d3.js d3.hcl()用法及代碼示例
- PHP sin( )用法及代碼示例
- PHP abs()用法及代碼示例
- PHP cos( )用法及代碼示例
- PHP Ds\Set xor()用法及代碼示例
- d3.js d3.map.set()用法及代碼示例
- PHP next()用法及代碼示例
- PHP pow( )用法及代碼示例
- d3.js d3.sum()用法及代碼示例
- d3.js d3.mean()用法及代碼示例
注:本文由純淨天空篩選整理自Mahadev99大神的英文原創作品 CSS | calc() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。