IE7模式对话框-定位错误?

如何解决IE7模式对话框-定位错误?

| 更新资料 我发现了实际的问题。 在我的代码中,我指的是覆盖层的高度, 在除IE7之外的所有浏览器中,此值均与窗口大小相同,但是在IE7中,此值为文档大小。 所以我将其更改为引用窗口大小,并且它可以工作:)。 所以我现在的问题是,为什么IE7会这样做,我是否正确假设IE7是这里的犯规球? 原版的 我正在创建一个模式对话框脚本(供我自己使用)。 该代码可以完美地工作。 谷歌浏览器, Firefox, IE8 + 但是在IE7中,定位完全错误。 例 这些是我在IE9和IE7中获得的定位值(请注意,由于我打开了开发工具,因此这些值比正常窗口要小。)   IE7   左:367px;   顶部:1409px;      IE9   左:369.5px;   顶部:122.5px; 我需要做什么来解决这个问题? CSS 请注意,此CSS具有一些奇怪的规则,例如body标签仅用于测试目的。 请注意,我知道rgba,box-shadow等在css3不支持的浏览器中不起作用, 对话框正常运行时,我将修复此问题。
body {
  padding: 0;
  margin: 0;
  color: #fff;
  height: 3000px;
}

#modal-overlay {
  position: fixed;
  width: 100%;
  height: 100%;
  background: rgba(0,0.8);
  z-index: 9999;
  display: none;
}

#modal-dialog {
  display: none;
  background: #000;
  border-bottom: 1px solid #141414;
  border-right: 1px solid #141414;
  border-top: 1px solid #121212;
  border-left: 1px solid #121212;
  position: absolute;
  z-index: 99999;
  -webkit-box-shadow: 3px 3px 10px #000000;
  -moz-box-shadow: 3px 3px 10px #000000;
  box-shadow: 3px 3px 10px #000000;
}

#modal-element{
  margin-top: 16px;
  overflow-x: hidden;
  overflow-y: auto;
}

#test,#test2 {
  display: none;
  width: 800px;
  padding: 5px;
}

#test2 {
  width: 600px;
}

#modal-close {
  position: absolute;
  background-image: url(\'close.png\');
  width: 16px;
  height: 16px;
  top: -5px;
  right: -5px;
  cursor: pointer;
}

#modal-title {
  position: absolute;
  top: -10px;
  left: 5px;
  color: #fff;
  font-size: 16px;
  font-weight: bold;
}

#modal-close:hover {
  -webkit-box-shadow: inset -1px -1px 10px rgba(0,0.8);
  -moz-box-shadow: inset -1px -1px 10px rgba(0,0.8);
  box-shadow:  inset -1px -1px 10px rgba(0,0.8);
}

#modal-close:active {
  -webkit-box-shadow: inset -5px -5px 10px rgba(0,0.8);
  -moz-box-shadow: inset -5px -5px 10px rgba(0,0.8);
  box-shadow:  inset -5px -5px 10px rgba(0,0.8);
}
Javascript
(function($) {

    $.widget(\"hailwood.modal\",{

        options: {
            width: null,height: null,title: \'\',closeOnEscape: true,modal: true
        },self: {},_create: function() {

            //setup our elements
            var self = this;

            this.body = $(\'body\');
            this.content = self.element;
            this.place = $(\'<div id=\"modal-place\" style=\"display:none;\"></div>\');
            this.dialog = $(\'<div id=\"modal-dialog\"><div id=\"modal-element\"></div></div>\');
            this.stuff = $(\'#modal-element\',this.dialog);
            this.overlay = $(\'<div id=\"modal-overlay\"></div>\');
            this.title = $(\'<div id=\"modal-title\">\' + this.options.title + \'</div>\');
            this.closeButton = $(\'<div id=\"modal-close\"></div>\');


            //shove the placeholder element in
            this.content.after(this.place);

            //capture width and height
            this.orig_width = (this.options.width === null ? this.content.outerWidth(true) : this.options.width);
            this.orig_height = (this.options.height === null ? this.content.outerHeight(true) : this.options.height);

            //insert elements into the dom
            this.body.prepend(
                    this.overlay.prepend(
                            this.dialog.prepend(
                                    this.stuff.prepend(this.content)
                                    )
                                    .prepend(this.closeButton)
                                    .prepend(this.title)));

            //make the content visible
            this.content.show();

            this.refresh(this);

            //show the overlay and dialog
            this.overlay.fadeIn(\'medium\',function(){
                self.dialog.show(\'slide\',{direction: \'down\'},\'medium\');
            });

            //setup the resize handler
            $(window).resize(function() {
                self.refresh();
            });

            this.closeButton.click(function() {
                self.close();
            });

            if (this.options.closeOnEscape)
                $(document).bind(\'keyup.hailwood.modal\',function(e){
                    if (e.keyCode == 27)
                        self.close();
                });

            //setup close handler
            this.self = this;

        },close: function() {
            this.destroy();
        },refresh: function() {
            var self = this;
            if (self.overlay.length == 0 || self.dialog.length == 0)
                return false;

            self.height = self.orig_height;
            self.width = self.orig_width;

            //make an adjustment to the height if it is bigger than the overlay
            var s1 = self.height;
            self.height = (self.height > self.overlay.height() ? self.overlay.height() - 20 : self.height);

            var diff = (s1 === self.height ? 0 : 16);

            //set the dialog height and width
            self.dialog.height(self.height);
            self.dialog.width(self.width);
            self.stuff.height(self.height -diff);
            self.stuff.width(self.width);

            //position the dialog
            self.left = (self.overlay.width() / 2) - (self.dialog.outerWidth() / 2);
            self.top = (self.overlay.height() / 2) - (self.dialog.outerHeight() / 2);

            self.dialog.css({left : self.left,top  : self.top});

        },destroy: function() {
            var self = this;
            self.dialog.hide(\'slide\',\'medium\',function() {
                self.place.after(self.content.hide());
                self.place.remove();
                self.dialog.remove();
                $(window).unbind(\'.hailwood.modal\');
                $(document).unbind(\'hailwood.modal\');
                self.overlay.fadeOut(\'medium\',function() {
                    self.overlay.remove();
                });
            });
            $.Widget.prototype.destroy.call(this);

        }
    });
    /*
     * Remember what I said in the first comment?
     * we pass in jQuery here so it gets aliased as $
     */
})(jQuery);
    

解决方法

尝试删除此行:
   body {
        height: 3000px;
    }
当我测试时并没有影响FF,而且我真的没有看到它的用处。 尝试使CSS东西正常工作时,最好总是删除不必要的代码,这样就可以确定问题的根源,除非您认为盒子阴影可能与您的定位问题有关。     

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-