Get the App
SLTechnology News&Howtos  ›  Development  › 

How css uses calc () to do arithmetic

Shulou Source: shulou.com Published: 2022-06-01 05:36:44 10月03日 Update

This article mainly shows you "how css uses calc () to do arithmetic". The content is simple and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "how css uses calc () to do arithmetic".

Use calc () to do arithmetic

*, but not the least, let's talk about the calc () function. This function allows you to perform simple arithmetic calculations, such as calculating the length and width of elements, eliminating the need for you to write Javascript code that is difficult to maintain. This function supports all simple basic arithmetic operations, including addition, subtraction, multiplication and division.

For example, you want to create an element whose width is full of its parent element, but also set aside some pixel width for other purposes:

.parent {width: 100%; border: solid black 1px; position: relative;} .child {position: absolute; left: 100px; width: calc (90%-100px); background-color: # ff8; text-align: center;} above is all the content of the article "how css uses calc () to do arithmetic". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Arithmetic elements content articles functions learning help important not easy addition subtraction multiplication and division code pixels function width easy to understand more organization usefulness knowledge tape Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Xiaomi Shulou Tech Info Microsoft OPPO Reno