问题
Due to the system i'm having to build a site in templates are extremely restrictive so I don't have much control.
My question is:
Is it possible with fancybox to set the width and height in the link?
e.g.
<a href="iframelocation" class="fancybox 480 320">Click here"</a>
Thanks in advance.
PVS
回答1:
You could store the values in data-
attributes. (assuming you are using jQuery 1.4.3 or greater)
<a href="iframelocation" class="fancybox" data-width="480" data-height="320">Click here"</a>
$("a.fancybox").each(function(){
var $a = $(this);
var h = $a.data("height")
var w = $a.data("width");
$a.fancybox({
'width' : w,
'height': h
});
});
回答2:
I'd recommend using HTML5 data-* attributes.
<a href="iframelocation" class="fancybox" data-width="480" data-height="320">Click here"</a>
来源:https://stackoverflow.com/questions/5378565/fancybox-declaring-size-in-link