我大的,透明的背景图像之前使用的相同JPG + PNG伎俩。把你的大图片和削减它分成2种类型的长方形片:
- 那些不需要透明度(保存为JPG)
- 那些确实需要透明度(保存为PNG)
目标是获得尽可能多的图像细节保存为JPG。
下一步,你需要使用相对和绝对定位拼凑一切重新走到一起:
<div class="bg">
<div class="content">
http://slipsum.com
</div>
<div class="section top"></div>
<div class="section middle"></div>
<div class="section bottom"></div>
</div>
.bg {
width: 600px; /* width of your unsliced image */
min-height: 800px; /* height of your unsliced image, min-height allows content to expand */
position: relative; /* creates coordinate system */
}
/* Your site's content - make it appear above the sections */
.content {
position: relative;
z-index: 2;
}
/* Define the sections and their background images */
.section {
position: absolute;
z-index: 1;
}
.section.top {
width: 600px;
height: 200px;
top: 0;
left: 0;
background: url(top.png) no-repeat 0 0;
}
.section.middle {
width: 600px;
height: 400px;
top: 200px;
left: 0;
background: url(middle.jpg) no-repeat 0 0;
}
.section.bottom {
width: 600px;
height: 200px;
top: 600px;
left: 0;
background: url(bottom.png) no-repeat 0 0;
}
来源
2011-09-22 00:11:19
Pat
我不明白你怎么只是非透明区域创建JPEG和使用PNG“只是透明区域'。你的意思是作为一个面具吗? – DMan
浏览器很少有一致的像素完美结果。 – Blender