CSS Sprites 在图像上显示损坏的图像图标,但悬停仍然有效

2023-11-29前端开发问题
30

本文介绍了CSS Sprites 在图像上显示损坏的图像图标,但悬停仍然有效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我想不通..希望其他人可以.

我有一个图像按钮.悬停效果很好.但是,我在按钮图像上显示了 IE 损坏的图像图标.

看这里:时髦图片 Funky Image Hover

如您所见......它们都可以工作,除了那个烦人的破碎图像.

这是我的 CSS:

<上一页>.donate-btn{背景:透明 url(/custom/img/donate-btn.png) 无重复;溢出:隐藏;高度:45px;宽度:210px;向左飘浮;}.donate-btn:悬停{背景:透明 url(/custom/img/donate-btn.png) 无重复;高度:45px;宽度:210px;背景位置:0 -45px;}

解决方案

这仅仅意味着你在 source 属性中引用了一个不存在的图像.您应该考虑改用实际的 <button> 标签.它只需要一些额外的样式属性来移除边框和填充:

.donate-btn{背景:透明 url(/custom/img/donate-btn.png) 0 0 不重复;溢出:隐藏;高度:45px;宽度:210px;边框:无;填充:0;向左飘浮;}.donate-btn:悬停{背景位置:0 -45px;}

我还通过删除悬停状态下的一些不必要的样式来简化您的 CSS.

<button class="donate-btn" type="submit"></button>

I can't figure this out..hopefully someone else can.

I have an image button . The hover effect works fine. However, I have the IE broken image icon over the button image.

Lookie here: Funky Image Funky Image Hover

As you can see...they both work except for that annoying broken image.

Here's my CSS:

.donate-btn{
background: transparent url(/custom/img/donate-btn.png) no-repeat;
overflow:hidden;
height:45px;
width:210px;
float:left;
}
.donate-btn:hover{
background: transparent url(/custom/img/donate-btn.png) no-repeat;
height:45px;
width:210px;
background-position: 0 -45px;
}

解决方案

This simply means you are referencing a non-existent image in the source attribute. You should consider using the actual <button> tag instead. It just needs a few extra style attributes to remove borders and padding:

.donate-btn{
    background: transparent url(/custom/img/donate-btn.png) 0 0 no-repeat;
    overflow:hidden;
    height:45px;
    width:210px;
    border: none;
    padding: 0;
    float:left;
}

.donate-btn:hover{
    background-position: 0 -45px;
}

I also simplied your CSS by removing some unnecessary styling in the hover state.

<button class="donate-btn" type="submit"></button>

这篇关于CSS Sprites 在图像上显示损坏的图像图标,但悬停仍然有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

ajax请求获取json数据并处理的实例代码
ajax请求获取json数据并处理的实例代码 $.ajax({ type: 'GET', url: 'https://localhost:44369/UserInfo/EditUserJson',//请求数据 data: json,//传递数据 //dataType:'json/text',//预计服务器返回的类型 timeout: 3000,//请求超时的时间 //回调函数传参 suc...
2024-11-22 前端开发问题
215

layui 实现实时刷新一个外部的div
主页面上显示了一个合计,在删除和增加的时候需要更改这个总套数的值: //html代码div class="layui-inline layui-show-xs-block" style="margin-left: 10px" id="sumDiv"spanSOP合计:/spanspan${totalNum}/spanspan套/span/div 于是在我们删除这个条数据后,...
2024-11-14 前端开发问题
156

layui 单选框、复选框、下拉菜单不显示问题如何解决?
1. 如果是ajax嵌套了 页面, 请确保 只有最外层的页面引入了layui.css 和 layui.js ,内层页面 切记不要再次引入 2. 具体代码如下 layui.use(['form', 'upload'], function(){ var form = layui.form; form.render(); // 加入这一句});...
2024-11-09 前端开发问题
313

layui要如何改变时间日历布局大小?
问题描述 我想改变layui时间日历布局大小,这个要怎么操作呢? 解决办法 可以用css样式对时间日历进行重新布局,具体代码如下: !DOCTYPE htmlhtmlheadmeta charset="UTF-8"title/titlelink rel="stylesheet" href="../../layui/css/layui.css" /style#test-...
2024-10-24 前端开发问题
271

Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript
Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)...
2024-04-20 前端开发问题
5

“数组中的每个孩子都应该有一个唯一的 key prop"仅在第一次呈现页面时
quot;Each child in an array should have a unique key propquot; only on first time render of page(“数组中的每个孩子都应该有一个唯一的 key prop仅在第一次呈现页面时)...
2024-04-20 前端开发问题
5