未使用jQuery resize()调整div的大小 我正在使用jQuery和Foundation框架。它内置于Wordpress主题中,这就是为什么我必须使用“jQuery”而不是简写的$表示
jQuery在加载页面时调整幻灯片的大小。但是,如果我调整浏览器窗口的大小,它将不会调整大小。我试过很多东西,但都没用。(边框框、单独的函数、不同的语法)未使用jQuery resize()调整div的大小 我正在使用jQuery和Foundation框架。它内置于Wordpress主题中,这就是为什么我必须使用“jQuery”而不是简写的$表示,jquery,wordpress,dom,resize,Jquery,Wordpress,Dom,Resize,jQuery在加载页面时调整幻灯片的大小。但是,如果我调整浏览器窗口的大小,它将不会调整大小。我试过很多东西,但都没用。(边框框、单独的函数、不同的语法) 您可以将代码放入resize事件中,并在页面加载时触发它。您还可以使用IIF在代码中使用$。你当然应该尝试限制大小调整,但现在这很酷 // We can use $ inside here... (function($){ // When the document is ready this is called... $(funct
您可以将代码放入
resize
事件中,并在页面加载时触发它。您还可以使用IIF在代码中使用$。你当然应该尝试限制大小调整,但现在这很酷
// We can use $ inside here...
(function($){
// When the document is ready this is called...
$(function(){
// We'll be using thise more than once!
var $window = $(window);
// Whenever a resize event occurs, do this...
$window.on('resize', function(e){
var width = $window.width(),
height = $window.height() - $('.top-bar').height();
$('.slide').height(height).width(width);
$('.slide4 > div > img').height(height*.5);
// The "trigger" fakes the event on load...
}).trigger('resize');
})
})(jQuery); // You're passing jQuery to the IIF, so this is why you can use $ inside.
希望这有帮助
// We can use $ inside here...
(function($){
// When the document is ready this is called...
$(function(){
// We'll be using thise more than once!
var $window = $(window);
// Whenever a resize event occurs, do this...
$window.on('resize', function(e){
var width = $window.width(),
height = $window.height() - $('.top-bar').height();
$('.slide').height(height).width(width);
$('.slide4 > div > img').height(height*.5);
// The "trigger" fakes the event on load...
}).trigger('resize');
})
})(jQuery); // You're passing jQuery to the IIF, so this is why you can use $ inside.