Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> CSS

การคำนวณค่าคุณสมบัติ CSS ด้วยฟังก์ชัน calc()


สามารถดึงค่าของคุณสมบัติใน CSS ได้โดยใช้ฟังก์ชัน calc() คุณสามารถลองรันโค้ดต่อไปนี้เพื่อนำฟังก์ชัน calc() ไปใช้ใน CSS ได้

ตัวอย่าง

<!DOCTYPE html> <html>    <head>       <style>          #demo {             position: absolute;             width: calc(100% - 100px);             background-color: blue;             text-align: center;          }       </style>    </head>    <body>       <h1>Heading One</h1>       <div id = "demo">This is it!</div>    </body> </html>