IE 9 的子元素不透明,我无法使用 captify 阻止它

2024-05-09

好的,我正在使用一段名为 Captify 的 javascript。它为您的图像添加了一个带有文本的小弹出窗口。适用于所有接受 IE9 的浏览器。 IE9 会淡化弹出 div 中的所有内容。我已阅读其子元素问题,但无法修复它。由于在网上任何地方都找不到 captify,我将包含所有代码以及下面的 css,然后是我页面上的代码。如果有人能帮助我阻止褪色,我将非常感激,因为它给我带来了重大问题。

Java

jQuery.fn.extend({
captify: function(o){
    var o = $.extend({
        speedOver: 'fast',      // speed of the mouseover effect
        speedOut: 'normal',     // speed of the mouseout effect
        hideDelay: 500,         // how long to delay the hiding of the caption after mouseout (ms)
        animation: 'fade',      // 'fade' or 'slide'
        prefix: '',             // text/html to be placed at the beginning of every caption
        className: 'caption'    // the name of the CSS class to apply to the caption box
    }, o);
    $(this).each(function(){
        var img = this;
        $(this).load(function(){
            $this = img;
            if (this.hasInit){
                return false;
            }
            this.hasInit = true;
            var over_caption = false;
            var over_img     = false;
            //pull the label from another element if there if there is a 
            //valid element id inside the rel="..." attribute, otherwise,
            //just use the text in the title="..." attribute.
            var captionLabelSrc = $('#' + $(this).attr('rel'));
            var captionLabelTitle = !captionLabelSrc.length ? $(this).attr('title') : captionLabelSrc.html();
            var captionLabelHTML = !captionLabelTitle.length ? $(this).attr('alt') : captionLabelTitle;
            captionLabelSrc.remove();
            var toWrap = this.parent && this.parent.tagName == 'a' ? this.parent : $(this);
            var wrapper = toWrap.wrap('<div></div>').parent();
            wrapper.css({
                overflow: 'hidden',
                padding: 0,
                fontSize: 0.1
            })
            wrapper.addClass('caption-wrapper');
            wrapper.width($(this).width());
            wrapper.height($(this).height());
            //transfer the border properties from the image to the wrapper
            $.map(['top','right','bottom','left'], function(i){
                $.map(['style','width','color'], function(j){
                    var key = 'border-'+i+'-'+j;
                    wrapper.css(key, $(img).css(key));
                });
            });
            $(img).css({border: '0 none'});
            //transfer the margin properties
            $.map(['top','right','bottom','left'], function(t){
                var key = 'margin-'+t;
                wrapper.css(key, $(img).css(key));
            });

            //create two consecutive divs, one for the semi-transparent background,
            //and other other for the fully-opaque label
            var caption         = $('div:last', wrapper.append('<div></div>')).addClass(o.className);
            var captionContent  = $('div:last', wrapper.append('<div></div>')).addClass(o.className).append(o.prefix).append(captionLabelHTML);

            //override hiding from CSS, and reset all margins (which could have been inherited)
            $('*',wrapper).css({margin: 0}).show();
            //ensure the background is on bottom
            var captionPositioning = jQuery.browser.msie ? 'static' : 'relative';
            caption.css({
                zIndex: 1,
                position: captionPositioning
            });

            //clear the backgrounds/borders from the label, and make it fully-opaque
            captionContent.css({
                position: captionPositioning,
                zIndex: 2,
                background: 'none',
                border: '0 none',
                opacity: 1.0
            });
            caption.width(captionContent.outerWidth());
            caption.height(captionContent.outerHeight());

            //pull the label up on top of the background
            captionContent.css({ 'marginTop': -caption.outerHeight() });
            //function to push the caption out of view
            var cHide = function(){
                if (!over_caption && !over_img)
                    caption.animate({ marginTop: 0 }, o.speedOut); 
            };
            //when the mouse is over the image
            $(this).hover(
                function(){ 
                    over_img = true;
                    if (!over_caption) {
                        caption.animate({
                            marginTop: -caption.height()
                        }, o.speedOver);
                    }
                }, 
                function(){ 
                    over_img = false;
                    window.setTimeout(cHide, o.hideDelay);
                }
            );

            //when the mouse is over the caption on top of the image (the caption is a sibling of the image)
            $('div', wrapper).hover(
                function(){ over_caption = true; },
                function(){ over_caption = false; window.setTimeout(cHide, o.hideDelay); }
            );
        });
        //if the image has already loaded (due to being cached), force the load function to be called
        if (this.complete || this.naturalWidth > 0){
            $(img).trigger('load');
        }
    });
}
});

现在是 captify 的 CSS

/* caption styling */

.caption {
color: #ffffff;
padding: 0.6em;
font-size: 10px;
display: none;
cursor: default;
/* remove these 4 lines below if you want 
the caption to span the whole width of the 
image
width: 82%;
/*border-top: 1px solid #303030;
border-right: 1px solid #303030;*/

/* background / transparency */
background: #000000;
opacity: 0.7;
filter: alpha(opacity=70);
-moz-opacity: 0.7;
-khtml-opacity: 0.7;
margin-bottom: 5px;
}

.caption a {
border: 0 none;
text-decoration: none;
background: #000000;
padding: 0.3em;
color:#FFFF00;
}

.caption a:hover {

text-decoration:underline;
}

.caption-wrapper {
float: left;
}

br.c { clear: both; }

现在是我的页面

<link href="/js/captify/sample.css" rel="stylesheet" type="text/css" /><script     type="text/javascript" src="/js/captify/captify.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('img.captify').captify({
    // all of these options are... optional
    // ---
    // speed of the mouseover effect
    speedOver: 150,
    // speed of the mouseout effect
    speedOut: 200,
    // how long to delay the hiding of the caption after mouseout (ms)
    hideDelay: 100,
    // 'fade' or 'slide'
    animation: 'fade',      
    // text/html to be placed at the beginning of every caption
    prefix: '', 
    // the name of the CSS class to apply to the caption box
    className: 'caption'
});
});
</script>

  <div id="services">

  <ul >

  <li >

      <img src="/images/sports.png" width="169" height="121" class="captify" rel="caption1" />
                <div id="caption1"><h4>Watersports</h4>
<p>View all the sports we offer on the lakeside.</p></div>   

  </li></ul></div>

和我使用的额外CSS

#services {
width: 570px;
margin-top: 370px;
height: 130px;
}
#services ul li {
float: left;
height: 128px;
width: 184px;
margin-right: 5px;
} 

由于 IE 不透明度处理很糟糕,我建议你一起放弃。对于背景,您可以使用透明 png(1x1 重复)来获得相同的效果。或者,如果您仅使用 IE CSS,则可以定义背景以仅使用 IE 的 png。我认为这会为您节省大量时间来解决这个问题

编辑:当然不要忘记在 IE css 中将不透明度设置为 1

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

IE 9 的子元素不透明,我无法使用 captify 阻止它 的相关文章

  • bootstrap-select 未选择任何内容

    我正在使用引导选择
  • 如何在引导程序中制作两个等高的列?

    我有这个代码 HTML div class container fluid div class row div class col md 6 p Line p p Line p p Line p p Line p p Line p p Li
  • Lightbox:如何翻译“Image x of x”文本?

    我使用 Lightbox 2 作为图像集 当我的网站的访问者单击该集中的缩略图时 它将显示 图像的放大版本 下面是 描述 取自 a 标题属性 其下方 文本 Image x of x 例如 Image 1 of 12 有谁知道在哪里翻译 更改
  • 将屏幕宽度获取到 javascript 变量中并通过 ajax 将其发送到 php 页面以避免页面加载

    这是JS检测我的页面命名上的屏幕分辨率index html并将其发送到 php 以便可以使用以下方式检索值 GET 这是我的PHP文件命名的内容process php
  • 带有桌子的嵌套表

    我在应用了表排序器的表中嵌套了表 它在嵌套表中添加了排序标题 但是它们没有对行进行排序 并且抛出了JavaScript错误 我想拥有 嵌套表不可排序 巢表上的排序实际上可以工作 但不是现状 您的第一个选择要容易得多 使嵌套表不可排序 像这样
  • iPhone 上的全屏视频播放器是否有“onClose”事件?

    我在网站上使用 html5 视频播放器 当用户开始播放时 播放器进入全屏模式并播放视频 视频结束后 我看到ended事件并通过关闭视频播放器myvideo webkitExitFullScreen 现在 当玩家实际获得时我需要另一个事件cl
  • HTML/CSS:页面左侧的导航栏

    我发现创建这样具有良好语义的布局很尴尬 左侧是大约 150 像素宽的列 其中包含导航元素 我想将网站这部分的 HTML 放在 HTML 代码的开头 然后有一个简单的方法来强制页面的其余部分不侵占左侧的区域 150 像素列 我考虑过一些选择
  • Kendo 刷新 (DropDownList.refresh()) 不起作用错误未定义

    我试图在另一个 DropDownList 更改后刷新下拉列表 但 Refresh 方法未定义错误正在升级 我尝试再次读取数据源 它显示它正在加载 但数据仍然相同 帮助解决这个问题请 Code DropDownList1 change fun
  • 电子邮件模板中的剪贴板功能

    我想在电子邮件模板中发送优惠券代码 一个小按钮 用于复制剪贴板上输入元素的内容 通过电子邮件模板 我的意思是我想发送一封电子邮件 其中包含优惠券代码 并且电子邮件模板中会有一个按钮 允许我将其复制到剪贴板 这可以做到吗 任何帮助将不胜感激
  • 为什么我从 c# 到 js 得到不同的 MD5 哈希值?

    我有一个用于加密密码的 C 函数 System Security Cryptography MD5CryptoServiceProvider md5Provider new System Security Cryptography MD5C
  • 如何使 4.X Typescript 项目与旧版本的 Typescript(如 3.X)兼容?

    如何使基于 TS 4 X 构建的软件包与 3 X 兼容 例如 如果我有较新的版本 则使用新功能 否则使用any or unknown或旧版本支持的任何内容 有没有可能使用指令 https www typescriptlang org doc
  • 如何使用 API 中的数据填充选择的下拉元素 - ReactJS

    我对 React 还很陌生 我正在从 API 获取数据 当我检查控制台日志时可以看到数据 但是我不知道如何使用 map 创建一个新数组 然后选项元素可以使用该数组来显示货币代码 目前它填充下拉列表 但选项元素全部为空 结果显示为 NaN 下
  • Fancybox 只能水平响应高内容吗?

    我有一个网站 其中有一些非常高的图像 我希望这些图像能够以响应方式水平响应 但不能垂直响应 如果它们符合浏览器的高度 它们就会变得太小而无法正确查看 有没有一种简单的方法可以实现我所缺少的 请参阅下面的示例 单击第二个缩略图 bswift
  • 禁用移动设备上的锚点菜单点击

    我使用嵌套列表作为带有子菜单项的菜单 我曾经这样做过 如果您将鼠标悬停在主菜单项上 子菜单项将通过将显示从无更改为块来出现 我决定让子菜单看起来就像是下拉的 并使用了 CSS 过渡 我遇到的问题是 在第一种方法中 如果您触摸 iPad 上的
  • javascript 闭包和对象引用

    我的情况有点晦涩难懂 主要是因为我认为我已经掌握了闭包 所以基本上我想要的是将集合重置为默认值 假设我有一个集合 它具有带有对象参数数组的构造函数 var c new collection x y z 然后集合定期更新 因为我没有保留数组的
  • 如何在 Safari 和 Native App 之间共享上下文?

    我有需要通过 Safari 设置一些上下文 上下文标记 然后从本机 iOS 应用程序读取该上下文 这样做的最佳实践是什么 到目前为止的一些想法 在 HTML 5 数据库中设置上下文 但我不确定这是否有效 因为该数据库可能只能从 Safari
  • 从“class”名称中删除/替换不需要的前缀信息

    我正进入 状态style从后端 它带有不需要的前缀 我会替换没有前缀的相同内容 正确的方法是什么 这就是我得到的
  • 为什么 phantomjs 不能在 MacOS Sierra 中工作?

    我们正在使用phantomjs 1 9 1 macosx phantomjs 2 0 0 macosx哪一个工作得很好OS X 埃尔卡皮坦更新后macOS 塞拉利昂它会引发以下错误 phantomjs 1 9 1 macosx phanto
  • 尽管 getBoundingClientRect() 是假的,但如何将事件坐标转换为 SVG 坐标?

    我正在尝试根据鼠标的位置在 SVG 元素上动态绘制内容 不幸的是 我很难将 mousemove 事件中的鼠标坐标转换为 SVG 元素的坐标空间 这是我一直在测试的一个有缺陷的函数 CylinderDemo prototype handleM
  • 用于替换前 5 个数字的正则表达式,无论它们之间有什么?

    我正在努力实现以下匹配 Input 123 45 6789 123456789 1234 正则表达式尝试输出 d 5 123 45 6789 123456789 1234 d 2 3 123 45 6789 123456789 1234 d

随机推荐

  • SDK 管理器中缺少 Google Play 服务

    我想在我的应用程序中使用 Google 地图 我想在 SDK 管理器中安装 Google Play 服务 但是当我转到 SDK 管理器时 我没有看到 Google Play 服务 为什么 我该如何安装这个 我可以独立于 SDK Manage
  • 如何清除整个终端(PowerShell)

    我有一个问题 在powershell中使用clear或cls命令仅清除终端的可见部分 我想知道如何清除整个终端 顺便说一句 我使用 VSCode tl dr 问题是关于清零的both屏幕和回滚缓冲区 in the 综合终端 of 视觉工作室
  • /proc/PID 文件格式

    我想从中检索一些流程信息 proc目录 我的问题如下 中的文件是否有标准格式 proc PID 例如 有这个proc PID status文件与Name t ProcName在第一行 我可以在其他地方用空格代替这个文件吗 t或者类似的东西
  • 找到的程序集的清单定义与程序集引用不匹配

    我试图在 C Windows 窗体应用程序 Visual Studio 2005 中运行一些单元测试 但出现以下错误 System IO FileLoadException 无法加载文件或程序集 实用程序 版本 1 2 0 200 文化 中
  • 从 org.w3c.dom.Node 获取 Xpath

    我可以从 org w3c dom Node 获取完整的 xpath 吗 假设当前节点指向 xml 文档中间的某个位置 我想提取该元素的 xpath 我正在寻找的输出 xpath 是 parent child1 chiild2 child3
  • 在 Android 5 上支持 BLE 外设角色的芯片组 [关闭]

    Closed 这个问题需要多问focused help closed questions 目前不接受答案 Android 5 0 Lollipop 引入的新 BLE 外设模式将不会在 Nexus 4 5 或 7 上启用 https code
  • 调用 Perl 子程序时使用 & 符号和括号

    usr bin perl sub t print in t n print n s sub s print in s n print n t 1 2 print out n print n Output in t 1 2 in s 1 2
  • Atom“自动完成”不起作用

    因此 当您安装 Atom 时 autocomplete 会随其一起提供 并且默认情况下处于启用状态 当我编写代码时 什么也没有显示 为什么 是否需要配置任何文件才能正常工作 In autocomplete plus settings pag
  • org.hibernate.MappingException:没有 JDBC 类型的方言映射:1111

    我使用的是 postgres v8 3 它的列类型为 XML DDL 看起来像这样 CREATE TABLE contact ID INTEGER NOT NULL NAME VARCHAR NOT NULL Details XML 在映射
  • 计算属性应该在模型或控制器中声明吗?

    具有以下用户模型 Sks User DS Model extend firstName DS attr string lastName DS attr string fullName 计算属性应该在哪里声明 fullName Ember c
  • 如何从对应的数组值中获取数组键?

    您可以轻松地通过其键获取数组值 如下所示 value array key 但如果我有该值并且想要它的密钥怎么办 获得它的最佳方式是什么 你可以使用array search https www php net manual en functi
  • 如何理顺 Laravel Blade @extends 的执行顺序?

    In 我尝试找到一种通过引用刀片 include来传递变量的方法 https stackoverflow com questions 25437939 how to pass variables by reference to includ
  • 从 Wikipedia XML 转储获取静态 HTML 文件

    我希望能够从巨大的 即使是压缩的 英语维基百科 XML 转储文件中获取相对最新的静态 HTML 文件enwiki 最新 pages articles xml bz2 http download wikimedia org enwiki la
  • 上传的白名单或黑名单文件扩展名?

    我正在制作一个新闻通讯编辑器 它将允许文件上传 新闻通讯的发件人可以将文件上传到将在电子邮件中链接到的服务器 该站点的设置使得只有 do URI 实际由 servlet 执行 处理 因此不会有太大的安全风险 但有人告诉我将 jsp php
  • 如何在不实例化一个类的情况下检查它是否继承了另一个类? [复制]

    这个问题在这里已经有答案了 假设我有一个如下所示的类 class Derived some inheritance stuff here 我想在我的代码中检查类似的内容 Derived is SomeType 但看起来像is运算符需要 De
  • Rails 3 - 如何完全避免数据库?

    我尝试在没有任何数据库后端的情况下使用 Rails 3 但当我尝试访问页面时它仍然坚持要求 sqlite3 gem 并抛出错误no such file to load sqlite3 尽管应用程序中没有代码需要 sqlite 但我将 dat
  • S3 存储桶可以生成自己的对象键名称吗?

    我正在将 Amazon API Gateway 配置为 S3 存储桶的代理 理想情况下 我希望客户端能够将文件发布到存储桶 让 S3 为其分配一个文件名 然后在响应中返回该名称 我不想让客户端能够指定文件名 这可能吗 设置代理的文档根本没有
  • 无法从 Web api POST 读取正文数据

    我正在尝试从新的 Asp Net Web Api 中的请求中提取一些数据 我有一个像这样的处理程序设置 public class MyTestHandler DelegatingHandler protected override Syst
  • 输入维度/分辨率会影响卷积神经网络的性能吗? [关闭]

    Closed 这个问题需要多问focused help closed questions 目前不接受答案 我正在构建一个图像分类器 其中有 66 个类和大约 50000 个图像 我的电脑内存为 12 GB 我的内存不足以训练图像 我的问题是
  • IE 9 的子元素不透明,我无法使用 captify 阻止它

    好的 我正在使用一段名为 Captify 的 javascript 它为您的图像添加了一个带有文本的小弹出窗口 适用于所有接受 IE9 的浏览器 IE9 会淡化弹出 div 中的所有内容 我已阅读其子元素问题 但无法修复它 由于在网上任何地