css - 最小高度 : 100vh not working in ie8

标签 css internet-explorer-8

In IE8 when i give min-height in vh then ie8 ignore it and not work.in other brower work well.some where i read that vh not support ie8 any solution that i use vh in ie8.

 <div class=" item Finish " id="Finish" style="overflow: visible!important;" >
        <div  style="background-color:  #27AE61!important;padding: 0px !important;min-height:85vh;overflow: visible!important;">

       <-- html code  -->                      
        </div>
 </div>

最佳答案

Silver Ringvee 的回答绝对正确,除了默认的 jQuery .css() 功能在您想要执行 .css('margin-right') 获取元素的右边距。我在使用 fancyBox 时发现了这个问题.我通过检查 props 是否为字符串来解决这个问题,如果是,则不使用 parseProps($.extend({}, props))。我还添加了检查是否给出了多个参数,以支持 css('margin-right', '12px')。这是我的代码:

(function ($, window) {
    var $win = $(window), _css = $.fn.css;

    function viewportToPixel(val) {
        var vwh_match = val.match(/[vwh]+/);
        var digits_match = val.match(/\d+/);
        if (vwh_match && vwh_match.length && digits_match && digits_match.length) {
            return (vwh_match[0] == 'vh' ? $win.height() : $win.width()) * (digits_match[0] / 100) + 'px';
        }
        return val;
    }

    function parseProps(props) {
        var p, prop;
        for (p in props) {
            prop = props[p];
            if (/[vwh]$/.test(prop)) {
                props[p] = viewportToPixel(prop);
            }
        }
        return props;
    }

    $.fn.css = function (props) {
        var self = this,
            originalArguments = arguments,
            update = function () {
                if (typeof props === 'string' || props instanceof String) {
                    if (originalArguments.length > 1) {
                        var argumentsObject = {};
                        argumentsObject[originalArguments[0]] = originalArguments[1];
                        return _css.call(self, parseProps($.extend({}, argumentsObject)));
                    } else {
                        return _css.call(self, props);
                    }
                } else {
                    return _css.call(self, parseProps($.extend({}, props)));
                }
            };
        $win.resize(update);
        return update();
    };
}(jQuery, window));

关于css - 最小高度 : 100vh not working in ie8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30907937/

相关文章:

JavaScript 源文件未在 IE8 弹出窗口中加载

html - 截断元素与非截断元素并排

html - 背景图像在 IE 8 中的位置不正确

css - IE8 float 错误地显示边距

html - 文本输入后将图标保留在表格单元格的右下角

html - 如何使无序列表导航移动友好

html - Bootstrap 4 进度条不显示

html - 是否可以使用纯 CSS 将最后一列粘在表格中?

html - 防止页面容器上出现水平滚动条

javascript - jqGrid 4.13.0 IE8 Object.create 错误