{"id":20395,"date":"2015-06-02T11:00:15","date_gmt":"2015-06-02T05:30:15","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=20395"},"modified":"2016-12-19T15:02:50","modified_gmt":"2016-12-19T09:32:50","slug":"working-with-css-calc","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/working-with-css-calc\/","title":{"rendered":"Working with CSS- calc()"},"content":{"rendered":"<h1 style=\"text-align: center;\">Working with CSS- calc()<\/h1>\n<p>These days CSS has the ability to do some cool stuff like animations, gradients, transforms,<br \/>\ncreating sophisticated interfaces with flexible box layouts etc.<\/p>\n<p>In this blog we will learn how to use the <strong>calc<\/strong><em><strong>()<\/strong><\/em> CSS function, which is very useful for calculation in CSS.<\/p>\n<h3><strong>How to use it:<\/strong><\/h3>\n<p>calc() allow us to use the mathematical formula within CSS with height, width and font-sizes etc. To measure we can use four maths operators add(+), subtract(-), multiply(*) and divide(\/).<\/p>\n<h3><strong>Syntax:<\/strong><\/h3>\n<p>[css]<\/p>\n<p>\twidth:calc(100% \/ 4);\t<\/p>\n<p>[\/css]<\/p>\n<h3><strong>Uses of calc() function:<\/strong><\/h3>\n<div>\n<div style=\"float: left; width: 40%; margin-right: 2%;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone  wp-image-20428\" style=\"margin: 0;\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/06\/sample.jpg\" alt=\"sample\" width=\"290\" height=\"484\" \/><\/div>\n<div style=\"float: left; width: 58%;\">\n<p>Suppose there is content <span style=\"color: #99cc00;\">&lt;div&gt;<\/span>\u00a0which is supposed to adjust height according to the height of the browser. Here is the tricky part of the problem\u00a0wherein the\u00a0content should be just below the header. We usually achieve it via plain old vanilla JavaScript or jQuery. But this can easily be achieved by using CSS calc() function.<\/p>\n<p>[css]<\/p>\n<p>.content{<br \/>\n\theight:90%; \/*fallback*\/<br \/>\n\theight:calc(100% &#8211; 40px);<br \/>\n}<\/p>\n<p>[\/css]<\/p>\n<\/div>\n<div style=\"clear: both;\"><\/div>\n<\/div>\n<h3><strong>Browser support:<\/strong><\/h3>\n<p>It is supported by almost all modern browsers. On desktop version it supports IE 9+, Safari 6+.<br \/>\nFor reference you can use the following link:<br \/>\n<a href=\"http:\/\/caniuse.com\/#search=calc%28%29\">http:\/\/caniuse.com\/#search=calc%28%29<\/a><\/p>\n<p>For browsers that don&#8217;t support <strong>calc()<\/strong>, \u00a0use the following polyfill:<br \/>\nhttps:\/\/github.com\/closingtag\/calc-polyfill<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Working with CSS- calc() These days CSS has the ability to do some cool stuff like animations, gradients, transforms, creating sophisticated interfaces with flexible box layouts etc. In this blog we will learn how to use the calc() CSS function, which is very useful for calculation in CSS. How to use it: calc() allow us [&hellip;]<\/p>\n","protected":false},"author":50,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":1},"categories":[1],"tags":[355,378],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/20395"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/50"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=20395"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/20395\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=20395"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=20395"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=20395"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}