简体   繁体   中英

CSS - dynamically calculate width for IE11 with out Jquery

My application works fine in IE8, now we are migrating to IE11. Please find the div css below

.contentDiv{
  height:expression(document.body.clientHeight - contentDiv.getBoundingClientRect().top);
  overflow-y:scroll;
}

Css expression has been depreciated now. Could you please suggest me how to calculate the dynamic div width height for IE11 and also it should work in IE8 also?

If you have jQuery on the site (and you should) then you could have jQuery quickly cycle through the elements with that class and set the height explicitly.

$(document).ready(function(){
    $('.contentDiv').each(function(){
        $(this).css('height',$(document).height() - $(this)[0].getBoundingClientRect().top);
    });
});

You'll want to keep the overflow-y:scroll; style definition in the CSS.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM