中国新声代谭芷昀:jQuery.ifixpng

来源:百度文库 编辑:中财网 时间:2024/05/05 19:52:49
Overview
As you know IE versions below 6 do not support png transparency. This plugin designed to fix that problem by applying appropriate filters to user specified elements, while keeping all element tags intact.
Plugin works well with both img elements within the DOM and css properties specified externally.
It is chainable.
Unlike some other png hack solutions, it does not replace/hide any of your html tags.
You can revert applied changes using .iunfixpng().
Extremely easy to use!
Known limitations
(I don't have solutions for those listed below yet - CSS features that are lost when the fix applied)
Always defaults to "background-position:top left" and you cannot reposition it.
Unable to perform "background-repeat:repeat-y" or "background-repeat:repeat-x" on a target.
For the hack to work your item needs to be visible.
Directions
Downloadjquery 1.2.1. orabove and of courseifixpng.
Savepixel.gif to images/pixel.gif.
And finally initiate the plugin. See below. I usediMakePostable to make code below viewable).
// apply to all png images
$('img[@src$=.png]').ifixpng();
// apply to all png images and to div#logo
$('img[@src$=.png], div#logo').ifixpng();
// apply to div#logo, undo fix, then apply the fix again
$('img[@src$=.png], div#logo').ifixpng().iunfixpng().ifixpng();
// apply to div#logo2, modify css property and add click event
$('div#logo2').ifixpng().css({cursor:'pointer'}).click(function(){ alert('ifixpng is cool!'); });;
Demo 1
Demo 1
Apply ifixpng to image with id #logo.
$('#logo').pngfix();
click here to toggle ifixpng/iunfixpng
$('#switch').toggle(function(){
$('#logo').iunfixpng();
}, function(){
$('#logo').ifixpng();
});
Demo 2
Demo 2

Apply ifixpng to image with id #logo2 and chain css property as well as click event.
$('#logo2').ifixpng().css({cursor:'pointer'}).click(function(){ alert('ifixpng is so cool!'); });
Demo 3
Demo 3
background:url(images/ifixpng-logo-writing.png) no-repeat;">

You can specify location of your pixel image manually too.
Apply ifixpng to div with id #nice.
$.ifixpng('media/pixel.gif');
$('div#nice').ifixpng();
Demo 4
Demo 4

width:225px;height:220px;border:2px dashed #FFF;">
www.khurshid.com

www.jquery.com


Links works inside png fixed area
www.khurshid.com
www.jquery.com
Credits
Jason fromwww.consil.co.uk
Fil
maserG
jonahfox
J. Zaefferer -bassistance.de
Thanks you very much to those who helped me to perfect the plugin, let me know if I missed anyone :)
consil.co.uk for identifying issues when base tag
Fil, for making it compatible to work with images with additional parameters. (.png?43899)
maserG, added support for working with sites implementing mod-rewrite (url-rewrite)
J. Zaefferer & jonahfox, when specifying URL via CSS, quotation marks are optional match(/^url\(["']?(.*\.png)["']?\)$/i)
J. Zaefferer:bassistance.de for ideas taken fromtooltip plugin
Site using the plugin
Let me know about the sites using the plugin, if you know any.
Online catalogue of Uzbek craft
simplyselling.net
poseprints.com
Contact
Please feel free to contact me at jquery[at]khurshid[dot]com.
or