我大的,透明的背景圖像之前使用的相同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