Which is superior, CSS transparency or PNG Transparency?

后端 未结 5 658
孤独总比滥情好
孤独总比滥情好 2021-01-02 16:04

Should I use PNG transparency or CSS transparency?

My first instinct is to go with CSS. However I heard somewhere that the filter in IE is slow and that I would get

5条回答
  •  北荒
    北荒 (楼主)
    2021-01-02 16:25

    I just did a quick non-scientific test in Firefox 3.0.11 on the mac.

    My test was to overlay a div and scroll up and down repeatedly.

    One used css:

    background: #000; opacity:0.8;
    

    The other used a 10px 24bit PNG of the same.

    I measured the following results with Activity monitor (so guessing,not exact)

    Firefox 3.0.11

    CSS opacity: approximately 60% cpu usage.

    PNG: approximately 20% cpu usage.

    Safari 4.0:

    CSS opacity: approximately 80% (with peaks of 120%!)

    PNG: approximately 76% (with no peaks at all)

    So as far as performance goes, it seems like a PNG is the winner.

提交回复
热议问题