Home
CSS
CSS Math Functions
Tryit: Using the calc() function
Run ❯
Get your
own
website
Result Size:
625 x 534
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <head> <style> #div1 { position: absolute; left: 50px; width: calc(100% - 100px); border: 1px solid black; background-color: yellow; padding: 5px; } </style> </head> <body> <h1>The calc() Function</h1> <p>Create a div that stretches across the window, with a 50px gap between both sides of the div and the edges of the window:</p> <div id="div1">Some text...</div> </body> </html>