脚本宝典收集整理的这篇文章主要介绍了js實例教程-JQuery插件Style定製化方法的分析與比較,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。小寶典致力於為廣大程序猿(媛)提供高品質的代碼服務,請大家多多光顧小站,小寶典在此謝過。
最近因為項目的需要,使用了一個jquery插件。把插件下下來后,很快我就發現,很多默認的插件Style不符合項目要求,必須要被修改。
在這個過程中,我發現自己先後使用了多種不同的方法實現插件Style的定製化。很高興最後找到了我認為最好的方法,對CSS的認識也加深了不少,感觸頗多。這篇文章就是對這些新的CSS的認識的一個梳理。
2JQuery 插件Style 定製化方法
2.1 初始化插件時輸入定製化對象
做的比較好的插件會在初始化時允許輸入定製化對象。
如果輸入定製化對象,插件會使用定製化對象中的值,例如,
代碼如下:
VAR adgallerySetting = {
width: 600, // Width of the image, set to false and IT will read the CSS width
height: 400, // Height of the image, set to false and it will read the CSS height
}
var galleries = $('.ad-gallery').adGallery(adgallerySetting);
. 代碼如下:
var adgallerySetting = {
// All callbacks has the AdGallery objects as 'this' reference
callbacks: {
// This gets fired right before old_image is about to go away, and new_image
// is about to come in
beforeImageVisible: function(new_image, old_image) {
// Do something wild!
var thing = "this is it";
//Change the plugin enhanced page
$(".ad-gallery .ad-image-wrapPEr .ad-image").removeAttr("style");
$(".ad-gallery .ad-image-wrapper .ad-image").css("width", "100%");
var width = $(".ad-gallery .ad-image-wrapper .ad-image img").attr("width");
$(".ad-gallery .ad-image-wrapper .ad-image img").attr("width", "100%");
$(".ad-gallery .ad-image-wrapper .ad-image .img").attr("width", 100%);
$(".ad-gallery .ad-image-wrapper .ad-image").attr("height", 100%);
}
}
};
. 代碼如下:
#descriptions .ad-image-description {
position: absolute;
}
#descriptions .ad-image-description .ad-description-title {
display: block;
}
.ad-gallery .ad-image-wrapper .ad-image {
width: 100% ! important;
left: 0px ! important;
}
最近因為項目的需要,使用了一個JQuery插件。把插件下下來后,很快我就發現,很多默認的插件Style不符合項目要求,必須要被修改。
在這個過程中,我發現自己先後使用了多種不同的方法實現插件Style的定製化。很高興最後找到了我認為最好的方法,對CSS的認識也加深了不少,感觸頗多。這篇文章就是對這些新的CSS的認識的一個梳理。
2JQuery 插件Style 定製化方法
2.1 初始化插件時輸入定製化對象
做的比較好的插件會在初始化時允許輸入定製化對象。
如果輸入定製化對象,插件會使用定製化對象中的值,例如,
代碼如下:
var adgallerySetting = {
width: 600, // Width of the image, set to false and it will read the CSS width
height: 400, // Height of the image, set to false and it will read the CSS height
}
var galleries = $('.ad-gallery').adGallery(adgallerySetting);
. 代碼如下:
var adgallerySetting = {
// All callbacks has the AdGallery objects as 'this' reference
callbacks: {
// This gets fired right before old_image is about to go away, and new_image
// is about to come in
beforeImageVisible: function(new_image, old_image) {
// Do something wild!
var thing = "this is it";
//Change the plugin enhanced page
$(".ad-gallery .ad-image-wrapper .ad-image").removeAttr("style");
$(".ad-gallery .ad-image-wrapper .ad-image").css("width", "100%");
var width = $(".ad-gallery .ad-image-wrapper .ad-image img").attr("width");
$(".ad-gallery .ad-image-wrapper .ad-image img").attr("width", "100%");
$(".ad-gallery .ad-image-wrapper .ad-image .img").attr("width", 100%);
$(".ad-gallery .ad-image-wrapper .ad-image").attr("height", 100%);
}
}
};
. 代碼如下:
#descriptions .ad-image-description {
position: absolute;
}
#descriptions .ad-image-description .ad-description-title {
display: block;
}
.ad-gallery .ad-image-wrapper .ad-image {
width: 100% ! important;
left: 0px ! important;
}
覺得可用,就經常來吧!Javascript技巧 腳本寶典 歡迎評論哦! js技巧,巧奪天工,精雕玉琢。小寶典獻醜了!
以上是脚本宝典为你收集整理的js實例教程-JQuery插件Style定製化方法的分析與比較全部内容,希望文章能够帮你解决js實例教程-JQuery插件Style定製化方法的分析與比較所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。