Files
wangxiaowei 5d7b75a14e first commit
2025-12-09 13:35:21 +08:00

759 lines
15 KiB
JSON

{
"title":"calc() as CSS unit value",
"description":"Method of allowing calculated values for length units, i.e. `width: calc(100% - 3em)`",
"spec":"https://w3c.github.io/csswg-drafts/css-values-3/#calc-notation",
"status":"cr",
"links":[
{
"url":"https://hacks.mozilla.org/2010/06/css3-calc/",
"title":"Mozilla Hacks article"
},
{
"url":"https://developer.mozilla.org/en/docs/Web/CSS/calc",
"title":"MDN Web Docs - calc"
},
{
"url":"https://webplatform.github.io/docs/css/functions/calc",
"title":"WebPlatform Docs"
}
],
"bugs":[
{
"description":"IE 9 - 11 and Edge do not support `width: calc()` on table cells. [Bug Report](https://web.archive.org/web/20171123043312/https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10982196/)"
},
{
"description":"IE 9 - 11 don't render `box-shadow` when `calc()` is used for any of the values"
},
{
"description":"IE10 crashes when a div with a property using `calc()` has a child with [same property with inherit](https://stackoverflow.com/questions/19423384/css-less-calc-method-is-crashing-my-ie10)."
},
{
"description":"IE10, IE11, and Edge < 14 don't support using `calc()` inside a `transform`. [Bug report](https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/104773/)"
},
{
"description":"IE11 is reported to have trouble with `calc()` with nested expressions, e.g. `width: calc((100% - 10px) / 3);` (i.e. it rounds differently)"
},
{
"description":"IE11 is reported to not support `calc()` correctly in [generated content](https://stackoverflow.com/questions/31323915/internet-explorer-incorrectly-calculates-percentage-height-for-generated-content)"
},
{
"description":"IE11 does not support transitioning values set with `calc()`"
},
{
"description":"Safari & iOS Safari (both 6 and 7) does not support viewport units (`vw`, `vh`, etc) in `calc()`."
},
{
"description":"IE & Edge are reported to not support calc inside a 'flex'. (Not tested on older versions)\r\nThis example does not work: `flex: 1 1 calc(50% - 20px);`"
},
{
"description":"IE does not support `calc()` on color functions. Example: `color: hsl(calc(60 * 2), 100%, 50%)`."
},
{
"description":"Firefox <48 does not support `calc()` inside the `line-height`, `stroke-width`, `stroke-dashoffset`, and `stroke-dasharray` properties. [Bug report](https://bugzilla.mozilla.org/show_bug.cgi?id=594933)"
},
{
"description":"Firefox <59 does not support `calc()` on color functions. Example: `color: hsl(calc(60 * 2), 100%, 50%)`. [Bug Report](https://bugzilla.mozilla.org/show_bug.cgi?id=984021)"
},
{
"description":"Firefox <66 does not support `width: calc()` on table cells. [Bug Report](https://bugzilla.mozilla.org/show_bug.cgi?id=957915)"
}
],
"categories":[
"CSS3"
],
"stats":{
"ie":{
"5.5":"n",
"6":"n",
"7":"n",
"8":"n",
"9":"a #2",
"10":"a #3",
"11":"a #3"
},
"edge":{
"12":"y",
"13":"y",
"14":"y",
"15":"y",
"16":"y",
"17":"y",
"18":"y",
"79":"y",
"80":"y",
"81":"y",
"83":"y",
"84":"y",
"85":"y",
"86":"y",
"87":"y",
"88":"y",
"89":"y",
"90":"y",
"91":"y",
"92":"y",
"93":"y",
"94":"y",
"95":"y",
"96":"y",
"97":"y",
"98":"y",
"99":"y",
"100":"y",
"101":"y",
"102":"y",
"103":"y",
"104":"y",
"105":"y",
"106":"y",
"107":"y",
"108":"y",
"109":"y",
"110":"y",
"111":"y",
"112":"y",
"113":"y",
"114":"y",
"115":"y",
"116":"y",
"117":"y",
"118":"y",
"119":"y",
"120":"y",
"121":"y",
"122":"y",
"123":"y",
"124":"y",
"125":"y",
"126":"y",
"127":"y",
"128":"y",
"129":"y",
"130":"y",
"131":"y",
"132":"y",
"133":"y",
"134":"y",
"135":"y",
"136":"y",
"137":"y",
"138":"y",
"139":"y",
"140":"y",
"141":"y",
"142":"y"
},
"firefox":{
"2":"n",
"3":"n",
"3.5":"n",
"3.6":"n",
"4":"y x",
"5":"y x",
"6":"y x",
"7":"y x",
"8":"y x",
"9":"y x",
"10":"y x",
"11":"y x",
"12":"y x",
"13":"y x",
"14":"y x",
"15":"y x",
"16":"y",
"17":"y",
"18":"y",
"19":"y",
"20":"y",
"21":"y",
"22":"y",
"23":"y",
"24":"y",
"25":"y",
"26":"y",
"27":"y",
"28":"y",
"29":"y",
"30":"y",
"31":"y",
"32":"y",
"33":"y",
"34":"y",
"35":"y",
"36":"y",
"37":"y",
"38":"y",
"39":"y",
"40":"y",
"41":"y",
"42":"y",
"43":"y",
"44":"y",
"45":"y",
"46":"y",
"47":"y",
"48":"y",
"49":"y",
"50":"y",
"51":"y",
"52":"y",
"53":"y",
"54":"y",
"55":"y",
"56":"y",
"57":"y",
"58":"y",
"59":"y",
"60":"y",
"61":"y",
"62":"y",
"63":"y",
"64":"y",
"65":"y",
"66":"y",
"67":"y",
"68":"y",
"69":"y",
"70":"y",
"71":"y",
"72":"y",
"73":"y",
"74":"y",
"75":"y",
"76":"y",
"77":"y",
"78":"y",
"79":"y",
"80":"y",
"81":"y",
"82":"y",
"83":"y",
"84":"y",
"85":"y",
"86":"y",
"87":"y",
"88":"y",
"89":"y",
"90":"y",
"91":"y",
"92":"y",
"93":"y",
"94":"y",
"95":"y",
"96":"y",
"97":"y",
"98":"y",
"99":"y",
"100":"y",
"101":"y",
"102":"y",
"103":"y",
"104":"y",
"105":"y",
"106":"y",
"107":"y",
"108":"y",
"109":"y",
"110":"y",
"111":"y",
"112":"y",
"113":"y",
"114":"y",
"115":"y",
"116":"y",
"117":"y",
"118":"y",
"119":"y",
"120":"y",
"121":"y",
"122":"y",
"123":"y",
"124":"y",
"125":"y",
"126":"y",
"127":"y",
"128":"y",
"129":"y",
"130":"y",
"131":"y",
"132":"y",
"133":"y",
"134":"y",
"135":"y",
"136":"y",
"137":"y",
"138":"y",
"139":"y",
"140":"y",
"141":"y",
"142":"y",
"143":"y",
"144":"y",
"145":"y",
"146":"y",
"147":"y",
"148":"y"
},
"chrome":{
"4":"n",
"5":"n",
"6":"n",
"7":"n",
"8":"n",
"9":"n",
"10":"n",
"11":"n",
"12":"n",
"13":"n",
"14":"n",
"15":"n",
"16":"n",
"17":"n",
"18":"n",
"19":"y x",
"20":"y x",
"21":"y x",
"22":"y x",
"23":"y x",
"24":"y x",
"25":"y x",
"26":"y",
"27":"y",
"28":"y",
"29":"y",
"30":"y",
"31":"y",
"32":"y",
"33":"y",
"34":"y",
"35":"y",
"36":"y",
"37":"y",
"38":"y",
"39":"y",
"40":"y",
"41":"y",
"42":"y",
"43":"y",
"44":"y",
"45":"y",
"46":"y",
"47":"y",
"48":"y",
"49":"y",
"50":"y",
"51":"y",
"52":"y",
"53":"y",
"54":"y",
"55":"y",
"56":"y",
"57":"y",
"58":"y",
"59":"y",
"60":"y",
"61":"y",
"62":"y",
"63":"y",
"64":"y",
"65":"y",
"66":"y",
"67":"y",
"68":"y",
"69":"y",
"70":"y",
"71":"y",
"72":"y",
"73":"y",
"74":"y",
"75":"y",
"76":"y",
"77":"y",
"78":"y",
"79":"y",
"80":"y",
"81":"y",
"83":"y",
"84":"y",
"85":"y",
"86":"y",
"87":"y",
"88":"y",
"89":"y",
"90":"y",
"91":"y",
"92":"y",
"93":"y",
"94":"y",
"95":"y",
"96":"y",
"97":"y",
"98":"y",
"99":"y",
"100":"y",
"101":"y",
"102":"y",
"103":"y",
"104":"y",
"105":"y",
"106":"y",
"107":"y",
"108":"y",
"109":"y",
"110":"y",
"111":"y",
"112":"y",
"113":"y",
"114":"y",
"115":"y",
"116":"y",
"117":"y",
"118":"y",
"119":"y",
"120":"y",
"121":"y",
"122":"y",
"123":"y",
"124":"y",
"125":"y",
"126":"y",
"127":"y",
"128":"y",
"129":"y",
"130":"y",
"131":"y",
"132":"y",
"133":"y",
"134":"y",
"135":"y",
"136":"y",
"137":"y",
"138":"y",
"139":"y",
"140":"y",
"141":"y",
"142":"y",
"143":"y",
"144":"y",
"145":"y",
"146":"y"
},
"safari":{
"3.1":"n",
"3.2":"n",
"4":"n",
"5":"n",
"5.1":"n",
"6":"y x",
"6.1":"y",
"7":"y",
"7.1":"y",
"8":"y",
"9":"y",
"9.1":"y",
"10":"y",
"10.1":"y",
"11":"y",
"11.1":"y",
"12":"y",
"12.1":"y",
"13":"y",
"13.1":"y",
"14":"y",
"14.1":"y",
"15":"y",
"15.1":"y",
"15.2-15.3":"y",
"15.4":"y",
"15.5":"y",
"15.6":"y",
"16.0":"y",
"16.1":"y",
"16.2":"y",
"16.3":"y",
"16.4":"y",
"16.5":"y",
"16.6":"y",
"17.0":"y",
"17.1":"y",
"17.2":"y",
"17.3":"y",
"17.4":"y",
"17.5":"y",
"17.6":"y",
"18.0":"y",
"18.1":"y",
"18.2":"y",
"18.3":"y",
"18.4":"y",
"18.5-18.6":"y",
"26.0":"y",
"26.1":"y",
"26.2":"y",
"TP":"y"
},
"opera":{
"9":"n",
"9.5-9.6":"n",
"10.0-10.1":"n",
"10.5":"n",
"10.6":"n",
"11":"n",
"11.1":"n",
"11.5":"n",
"11.6":"n",
"12":"n",
"12.1":"n",
"15":"y",
"16":"y",
"17":"y",
"18":"y",
"19":"y",
"20":"y",
"21":"y",
"22":"y",
"23":"y",
"24":"y",
"25":"y",
"26":"y",
"27":"y",
"28":"y",
"29":"y",
"30":"y",
"31":"y",
"32":"y",
"33":"y",
"34":"y",
"35":"y",
"36":"y",
"37":"y",
"38":"y",
"39":"y",
"40":"y",
"41":"y",
"42":"y",
"43":"y",
"44":"y",
"45":"y",
"46":"y",
"47":"y",
"48":"y",
"49":"y",
"50":"y",
"51":"y",
"52":"y",
"53":"y",
"54":"y",
"55":"y",
"56":"y",
"57":"y",
"58":"y",
"60":"y",
"62":"y",
"63":"y",
"64":"y",
"65":"y",
"66":"y",
"67":"y",
"68":"y",
"69":"y",
"70":"y",
"71":"y",
"72":"y",
"73":"y",
"74":"y",
"75":"y",
"76":"y",
"77":"y",
"78":"y",
"79":"y",
"80":"y",
"81":"y",
"82":"y",
"83":"y",
"84":"y",
"85":"y",
"86":"y",
"87":"y",
"88":"y",
"89":"y",
"90":"y",
"91":"y",
"92":"y",
"93":"y",
"94":"y",
"95":"y",
"96":"y",
"97":"y",
"98":"y",
"99":"y",
"100":"y",
"101":"y",
"102":"y",
"103":"y",
"104":"y",
"105":"y",
"106":"y",
"107":"y",
"108":"y",
"109":"y",
"110":"y",
"111":"y",
"112":"y",
"113":"y",
"114":"y",
"115":"y",
"116":"y",
"117":"y",
"118":"y",
"119":"y",
"120":"y",
"121":"y",
"122":"y"
},
"ios_saf":{
"3.2":"n",
"4.0-4.1":"n",
"4.2-4.3":"n",
"5.0-5.1":"n",
"6.0-6.1":"y x",
"7.0-7.1":"y",
"8":"y",
"8.1-8.4":"y",
"9.0-9.2":"y",
"9.3":"y",
"10.0-10.2":"y",
"10.3":"y",
"11.0-11.2":"y",
"11.3-11.4":"y",
"12.0-12.1":"y",
"12.2-12.5":"y",
"13.0-13.1":"y",
"13.2":"y",
"13.3":"y",
"13.4-13.7":"y",
"14.0-14.4":"y",
"14.5-14.8":"y",
"15.0-15.1":"y",
"15.2-15.3":"y",
"15.4":"y",
"15.5":"y",
"15.6-15.8":"y",
"16.0":"y",
"16.1":"y",
"16.2":"y",
"16.3":"y",
"16.4":"y",
"16.5":"y",
"16.6-16.7":"y",
"17.0":"y",
"17.1":"y",
"17.2":"y",
"17.3":"y",
"17.4":"y",
"17.5":"y",
"17.6-17.7":"y",
"18.0":"y",
"18.1":"y",
"18.2":"y",
"18.3":"y",
"18.4":"y",
"18.5-18.6":"y",
"26.0":"y",
"26.1":"y"
},
"op_mini":{
"all":"n"
},
"android":{
"2.1":"n",
"2.2":"n",
"2.3":"n",
"3":"n",
"4":"n",
"4.1":"n",
"4.2-4.3":"n",
"4.4":"a #1",
"4.4.3-4.4.4":"a #1",
"142":"y"
},
"bb":{
"7":"n",
"10":"y"
},
"op_mob":{
"10":"n",
"11":"n",
"11.1":"n",
"11.5":"n",
"12":"n",
"12.1":"n",
"80":"y"
},
"and_chr":{
"142":"y"
},
"and_ff":{
"144":"y"
},
"ie_mob":{
"10":"y",
"11":"y"
},
"and_uc":{
"15.5":"y"
},
"samsung":{
"4":"y",
"5.0-5.4":"y",
"6.2-6.4":"y",
"7.2-7.4":"y",
"8.2":"y",
"9.2":"y",
"10.1":"y",
"11.1-11.2":"y",
"12.0":"y",
"13.0":"y",
"14.0":"y",
"15.0":"y",
"16.0":"y",
"17.0":"y",
"18.0":"y",
"19.0":"y",
"20":"y",
"21":"y",
"22":"y",
"23":"y",
"24":"y",
"25":"y",
"26":"y",
"27":"y",
"28":"y",
"29":"y"
},
"and_qq":{
"14.9":"y"
},
"baidu":{
"13.52":"y"
},
"kaios":{
"2.5":"y",
"3.0-3.1":"y"
}
},
"notes":"Support can be somewhat emulated in older versions of IE using the non-standard `expression()` syntax.\r\n\r\nDue to the way browsers handle [sub-pixel rounding](https://johnresig.com/blog/sub-pixel-problems-in-css/) differently, layouts using `calc()` expressions may have unexpected results.",
"notes_by_num":{
"1":"Partial support in Android Browser 4.4 refers to the browser lacking the ability to multiply and divide values.",
"2":"Partial support in IE9 refers to the browser crashing when used as a `background-position` value.",
"3":"Partial support in IE10/IE11 refers to calc not working properly with various use cases mentioned in known issues"
},
"usage_perc_y":94.92,
"usage_perc_a":0.35,
"ucprefix":false,
"parent":"",
"keywords":"",
"chrome_id":"5765241438732288",
"shown":true
}