1

その場で div を作成し、別の div をカバーするルーチンを作成しました。私のコードはエラーなしで動作しますが、私がやろうとしているのは完璧ではありません。コードに論理的または css 関連の問題があると思います。だからここで私は自分のコードを提供しています。可能であればそれを修正してください。

私のhtml

<div id="box-outer">
    <div id="data-box">
        This is your data.
    </div>
 </div>
 <asp:Button ID="blinddwn" runat="server" Text="BLIND-2-DOWN" />

私のCSS

 #box-outer
    {
        overflow: hidden;
        height: 200px;
        width: 200px;
        margin: 20px;
        padding: 10px;
        background-color:Green;
    }

私のJqueryルーチン

 $(document).ready(function () {
        jQuery.fn.exists = function () { return this.length > 0; }

        jQuery.fn.blindToggle = function (speed, easing, callback) {
            var oDiv;
            var margin_top = this.outerHeight() + parseInt(this.css('paddingTop')) + parseInt(this.css('paddingBottom'));

            if ($("#BlindBox").exists() == false) {
                var _height = this.outerHeight();
                var _width = this.outerWidth();

                oDiv = $("<div id='BlindBox'></div>");
                oDiv.css("height", _height + 'px');
                oDiv.css("width", _width + 'px');
                oDiv.css("margin-top", ('-' + margin_top + 'px'));
                oDiv.css("padding", "10px");
                oDiv.css("background", "#e459e9");
                oDiv.css("position", "relative");
                oDiv.css("display", "none");
                this.append(oDiv);
            }
            else {
                oDiv = $('#BlindBox');
            }


            if (parseInt(oDiv.css('marginTop')) < 0) {
                oDiv.css('display', 'none');
            }

            return oDiv.animate({ opacity: 'toggle',
                marginTop: parseInt(oDiv.css('marginTop')) < 0 ? 0 : ('-' + margin_top + 'px')
            }, speed, easing, callback);

        };
    });

        $(document).ready(function () {
            $('#blinddwn').click(function () {
                $('#box-outer').blindToggle('slow');
                return false;
            });
        });

誰かがコードを実行すると、BlindBox div が box-outer という別の div を適切にカバーしていないことがわかります。私のルーチンを見て、何が問題なのか教えてください。可能であれば修正する

ここで別の URL リンクhttp://jsfiddle.net/tridip/YdnLd/8/を提供しています。ここをクリックするだけで、コードで完全にしようとしている効果が表示されます。私のコードでやりたいのと同じ効果。私のコードで何が問題なのか教えてください。ありがとう

4

0 に答える 0