私の Web サイトは 1 ページの Web サイトで、5 つの DIV がパネル (クラス名は .panel) として機能し、ブラウザー ウィンドウの高さと幅全体を引き伸ばすことができます。以下のコードは既にこれを行っており、うまく動作しますが、.panel/browser ウィンドウの高さよりも大きくなるコンテンツがあります。現在、このコンテンツは非表示になっています。つまり、.panel DIV は文字通りウィンドウの高さであり、他には何もありません。その中のコンテンツがブラウザウィンドウの高さよりも大きい場合は、拡大する必要があります。
以下のコードを編集して、この機能を追加するにはどうすればよいですか? それに応じてスタイルを設定できるように、この調整された DIV にクラス名を追加することはできますか?
// In my plugins.js file
function fitElements(){
var height=$(window).height();
var width=$(window).width();
$('.panel').css('height',height);
$('.panel').css('width',width)
};
// At the bottom of my HTML file (to call the function)
jQuery(document).ready(function($) {
fitElements();
});
// My current code also adjusts on browser resize - so would need this answer to do the same
$(window).resize(fitElements);