4

ブラウザ ウィンドウのビュー ポートに対して div を配置したいと思います。現在、ウィンドウ サイズに基づいて動的に配置されるいくつかの jquery を含むポップアップがありますが、それらは絶対配置されているため、ページの上部に基づいているため、下にスクロールして下のプロジェクトをクリックすると、ページ、ポップアップはビューポートの外のページの上部に配置されます…</p>

特に「Redcat」プロジェクトをクリックすると、ここで確認できます。 http://www.samuelfarfsing.com/test.php

ビューポートの現在の位置に対してこれらの div を配置する方法はありますか?

HTML:

<div class="container">
    <div class="project">
    <a class="close">Close &times;</a>
    <img src="/img/lova_popup_slide01.jpg" width="500" height="530" alt="" />
    </div>
    <div class="description"><p>Description</p></div>
</div>

Jクエリ:

$(document).ready(function() {
//Find & Open

$(".projectThumb").click(function(){
    $("#backgroundPopup").show();
        htmlName = $(this).find("img").attr("name");
        $("#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;

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

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

    //Slideshow Image to hide rest
            $(".container").each(function(){
            $(".project img", this).hide().filter(":first").show();
        });
    });
});
4

1 に答える 1

1

多分あなたはCSSを探してい{ position: fixed }ますか?

于 2009-09-12T17:07:51.610 に答える