0

「ストレッチ」のクラスを持つHTMLに画像があります。

現在、css を使用すると、ウィンドウのサイズが画面幅の 100% に変更されると、この画像のサイズも変更されます。また、ウィンドウのサイズが変更されているときに上に移動したいと思います。

これはjQueryで実行できると想定していますが、よくわかりません。基本的に、「トップ」の css 値は、画面の幅と同じように変更する必要があります。

現在サイズを変更しているcssは次のとおりです。

.stretch {
width: 100%;
height: auto;
min-height: 420px;
position: absolute;
top: -200px;
}

ありがとう、

ウェイド

4

2 に答える 2

3
var origWidth;
$(document).ready(function() {
    origWidth = $(window).width();  //store the window's width when the document loads
});

$(window).resize(function() {
    var curWidth = $(window).width(); //store the window's current width
    var delta = (curWidth- origWidth);
    $(".stretch").offset({top:($(".stretch").offset().top + delta)});
    origWidth = curWidth;
});
于 2010-05-23T04:20:44.347 に答える
0

相対 top値(パーセントなど)を使用します。

于 2010-05-23T02:33:22.870 に答える