ウィンドウのサイズを変更するときに.containerのサイズを変更するスクリプトを使用しています。これは私のページです:http://cjehost.com/qt/nipt/page6.phponWindowResizeを使用してサイズ変更時にコンテナを中央に配置する方法
ブラウザウィンドウのサイズを変更すると、コンテナのサイズが変更されますが、中央に収まらないことがわかります。私のコンテナを集中させる方法はありますか?ここに私のスクリプトは次のとおりです。
\t // Resize the map to fit within the boundaries provided
\t function resize(maxWidth, maxHeight) {
\t var image = $('img'),
\t imgWidth = image.width(),
\t imgHeight = image.height(),
\t newWidth = 0,
\t newHeight = 0;
\t if (imgWidth/maxWidth > imgHeight/maxHeight) {
\t newWidth = maxWidth;
\t } else {
\t newHeight = maxHeight;
\t }
\t image.mapster('resize', newWidth, newHeight, resizeTime);
\t }
\t // Track window resizing events, but only actually call the map resize when the
\t // window isn't being resized any more
\t function onWindowResize() {
\t var curWidth = $(window).width(),
\t curHeight = $(window).height(),
\t checking = false;
\t if (checking) {
\t return;
\t }
\t checking = true;
\t window.setTimeout(function() {
\t var newWidth = $(window).width(),
\t newHeight = $(window).height();
\t if (newWidth === curWidth &&
\t newHeight === curHeight) {
\t resize(newWidth, newHeight);
\t }
\t checking = false;
\t }, resizeDelay);
\t }
\t $(window).bind('resize', onWindowResize);
マイCSS:
.container {margin:0 auto;}
'$(ウィンドウ).resize(onWindowResize);' –
はちょうどこれを見て、それを追加しました - ありがとう。私のコンテナはこのページで反応しますが、特に小さなブレークポイントになると、中央にとどまることはありません。 15pxの左パッドがあり、右のバットが窓に当たっています。何か案は? – phillystyle123