HTML CSS examples for CSS:Function
The calc() function does calculation on the property value.
Value | Require | Description |
---|---|---|
expression | Required. | A mathematical expression. The operators can be used: + - * / |
The following code shows how to Use calc() to calculate the width of a <div> element:
<!DOCTYPE html> <html> <head> <style> #div1 {<!-- w ww. ja v a2s . c o m--> position: absolute; left: 50px; width: calc(100% - 100px); border: 1px solid black; background-color: red; padding: 5px; text-align: center; } </style> </head> <body> <div id="div1">Some text...</div> </body> </html>