透明背景上的图像不平滑
Not smooth image on transparent background
我对一些div产生了加载效果,我在它们上面放了一个透明的div,中间有一个加载图像。
这是CSS:
.gear-modal {
width: 100%;
height: 100%;
position: absolute;
z-index:2147483640;
overflow:hidden;
background-image:url('https://business.comcast.com/img/preloader.gif');
background-repeat:no-repeat;
background-position: center;
background-color:rgba(0,0,0,0.5);
}
请看这个jsfiddle演示:
http://jsfiddle.net/margwt9h/3/
正如您在演示中看到的,图像的边界在某种程度上不平滑,为什么会显示为这样?这是怎么解决的?
p.S:问题不在于加载的图像,相同的图像在其他地方看起来都很好,但在这里却不好。
是的,图像看起来真的像素化了。尝试使用不同的gif图像并调整宽度和高度。查看这个片段,我使用了不同的图像并设置了高度和宽度:)
function show_gear_modal(element){
$(element).css('position', 'relative');
var custom_modal_html = '<div class="gear-modal"></div>';
$(element).prepend(custom_modal_html);
$(element+' .gear-modal').fadeIn();
}
$('.show_loading').on('click', function(){
show_gear_modal('.my_div');
})
.gear-modal {
width: 100%;
height: 100%;
position: absolute;
z-index:2147483640;
overflow:hidden;
background-image:url('http://www.mytreedb.com/uploads/mytreedb/loader/ajax_loader_gray_350.gif');
background-size: 64px 64px;
background-repeat:no-repeat;
background-position: center;
background-color:rgba(0,0,0,0.5);
}
.my_div{
min-height: 400px;
}
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<div class="my_div">
Here is some Content....<br /><br /><br />
<a class="show_loading"><strong>Click here to show the loading</strong></a>
</div>
不,它实际上只是图像。图像边缘有难看的白色不透明像素。当你把一个纯黑色的背景放在它后面时,这是非常明显的。
如果你不喜欢它的样子,我建议你找一张不同的照片。
相关文章:
- Html页面上的多个Base64图像和平滑加载
- 图像动画不平滑
- 使用 jQuery 在滚动时平滑过渡图像
- 使用锚标记单击时平滑地显示大图像
- 通过设置SRC数据Javascript平滑淡入图像RGB
- 如何预加载这些图像以使此功能更平滑
- 平滑幻灯片.js图像预加载
- 使用 javascript 在移动设备上平滑拖动图像
- 在OpenLayers 3中禁用图像平滑
- 使用 jquery .animation 平滑调整图像大小,并缩放
- 一种在指定时间后更改的背景图像之间添加更平滑过渡的简单方法
- 新颂网站 - 滚动时从一个背景图像平滑过渡到下一个背景图像
- 使用javascript画布调整图像大小(平滑)
- 使用jquery平滑图像淡出、更改src和淡入
- 如何使用JQuery slideDown来平滑地降低图像
- 如何调整内部有不同大小图像的旋转木马的引导模式的大小,平滑
- 透明背景上的图像不平滑
- 如何使用纯javascript在屏幕上平滑地拖动图像
- 使用jquery平滑地更改每个导航菜单的网站背景图像
- 在jQuery手机中滑动时图像的平滑过渡