1

if elseステートメントにスタブを付けていますが、これを正しく記述しているかどうかはわかりません…popupHeightディメンションがwindowHeightディメンションよりも大きい場合、ビューポートの上部+10pxに配置されるように取得しようとしています… </ p>

$("#data").load("/content/" + htmlName + ".html", null, function(){
    //Set Variables
    var container = $(".container");
    var project = $(".project");
    var popupWidth = container.find(".project img:first").width();
    var popupHeight = container.find(".project img:first").height()+35;
    var windowWidth = document.documentElement.clientWidth;
    var windowHeight = document.documentElement.clientHeight;
    var x = ($(window).width() / 2 - popupWidth / 2) + $(window).scrollLeft();
    var y = ($(window).height() / 2 - popupHeight / 2) + $(window).scrollTop();

    //Set popup dimensions
    container.css("width" , popupWidth);
    container.css("height" , popupHeight);

    //Set popup CSS
    container.css({"position": "absolute", "left": x + "px", "z-index": "2" });
    project.css({"width": (popupWidth), "height": (popupHeight) });

    //Determine Position
    if(popupHeight>windowHeight) {
        container.css{("top": $(window).scrollTop(); + 10 + "px") 
        }else{
        container.css({"top": y + "px"});
        return;
        }
});
4

2 に答える 2

1

scrollTop()の後のセミコロンを取り除き、行の最後に配置します-

container.css{("top": $(window).scrollTop(); + 10 + "px")

次のようになります-

container.css({"top": $(window).scrollTop() + 10 + "px"});

css関数も再フォーマットする必要があります。上記のようになります。

于 2009-09-16T02:27:08.733 に答える
0

私はこれまでjQueryを使用したことがないので、間違っている可能性がありますが、この行のセミコロンは間違った場所にありませんか?

container.css{("top": $(window).scrollTop(); + 10 + "px") 
于 2009-09-16T02:27:21.910 に答える