简体   繁体   English

CSS-在没有Jquery的情况下动态计算IE11的宽度

[英]CSS - dynamically calculate width for IE11 with out Jquery

My application works fine in IE8, now we are migrating to IE11. 我的应用程序在IE8中运行良好,现在我们正在迁移到IE11。 Please find the div css below 请在下面找到div CSS

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

Css expression has been depreciated now. CSS表达式现在已贬值。 Could you please suggest me how to calculate the dynamic div width height for IE11 and also it should work in IE8 also? 您能否建议我如何计算IE11的动态div宽度高度,并且它也可以在IE8中使用?

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. 如果您在站点上有jQuery(并且应该这样做),则可以让jQuery快速遍历该类的元素并显式设置高度。

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

You'll want to keep the overflow-y:scroll; 您将要保持overflow-y:scroll; style definition in the CSS. CSS中的样式定义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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