I am trying to get a height in a div to be exactly 55px less then the parent div.
I tried to do this: height: calc(~"100% - 55px");
in less which creates this: height: calc(100% - 55px);
This works fine in Chrome and Firefox, but crashes on IE10.
It's not that it does not work but it crashes it. This is very strange i tried to find some info on line but can't see anything.
Also, this happens only with the height. If i were to use the calc()
method on the width it runs fine.
Any idea on how i can get to the bottom of this?
I used it to create a full-bleed utility class: .full-bleed { width: 100vw; margin-left: calc (50% - 50vw); } I’d say calc () is in my top 3 CSS things. I used it to make space for a sticky footer.
IE 10 can be targeted with the -ms-high-contrast-hack, but IE 11 cannot. I do not want to use JavaScript to detect the browser because this seems even hackier than using CSS hacks.
There are many lengths of CSS though, and they can all be used with calc (): Unitless numbers are acceptable too, for example line-height: calc (1.2 * 1.2); as well as angles like transform: rotate (calc (10deg * 5));.
This tutorial covers How to Compile LESS files and generates CSS files with tutorials with examples.. calc () is a function in CSS3 used to perform arthematics calculations on css attributes expression formed using arthematic operators and result value as output. The width is calculated as 80px for the given div in CSS.
I found the problem. There was a height:inherit inside one of the inside divs. Clearly IE gets super confused on this as the value is calculated and apparently not inheritable. All well now.
So in other words you can't do something like this:
<div style="height:100%">
<div style="height: calc(100% - 50px)">
<div style="height:inherit">
</div>
</div>
</div>
if you do IE10 will crash, here is an example : http://jsfiddle.net/wyRXp/1/
here i took out the inherit height: http://jsfiddle.net/wyRXp/2/ and it works fine.
Both above samples work fine in Firefox and Chrome
There's a known issue with calc()
in IE10
Internet Explorer (in accordance with the spec) does not accept calculations without spaces for additions/subtractions (ie. calc(100%-30px) is invalid, but calc(100% - 30px) works fine).
Refer to CanIUse.com.
Most probable reason of your crash is that the Less is removing spaces when escaping the value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With