0

Royalslider プラグインにロゴを重ねようとしています。レスポンシブ レイアウトに対応するために、100% 幅と柔軟な幅に設定されています。CSS を使用して Royalslider の上にロゴを配置しました。それは機能しますが、完全に私が望む方法ではありません。私は基本的にスライダーの現在の高さを計算し、CSS margin-top をその値を 1.5 で割った値に設定します。

ブラウザウィンドウのサイズに関係なく、垂直方向に中央揃えにしたいと考えています。これは可能ですか?私の数学は微調整が必​​要ですか?どんな考えでも大歓迎です。

関連 URL:

http://www.bigideaadv.com/big_idea_v2/

現在の HTML:

<div id="new-royalslider-1" class="royalSlider new-royalslider-1 rsUni rs-default-template" style="width:100%; height:450px;">
    <div class="rsContent">
        <img class="rsImg" src="http://www.bigideaadv.com/big_idea_v2/wp-content/uploads/2013/10/top_slide11-1024x560.jpg" alt="Entemanns slide"/>
    </div>
    <div class="rsContent">
        <img class="rsImg" src="http://www.bigideaadv.com/big_idea_v2/wp-content/uploads/2013/10/top_slide1-1024x560.jpg" alt="PGPF Slide"/>
    </div>
    <div class="rsContent">
        <img class="rsImg" src="http://www.bigideaadv.com/big_idea_v2/wp-content/uploads/2013/10/top_slide3-1024x560.jpg" alt="American Arbitration Association slide"/>
    </div>
    <div class="rsContent">
        <img class="rsImg" src="http://www.bigideaadv.com/big_idea_v2/wp-content/uploads/2013/10/top_slide4-1024x560.jpg" alt="GDLSK slide"/>
    </div>
    <div class="rsContent">
        <img class="rsImg" src="http://www.bigideaadv.com/big_idea_v2/wp-content/uploads/2013/10/top_slide5-1024x560.jpg" alt="uShuttl slide"/>
    </div>
</div>
<p id="floating-logo" class="align-center"><img src="wp-content/themes/skeleton/images/parallax_logo.png" /></p>

現在の CSS (p タグのみ):

#floating-logo {
    display: block;
    position: absolute;
    margin: 0 auto 0 auto;
    width: 100%;
    z-index: 3000;
}

#floating-logo img {
    margin: 0 auto 0 auto;
}

Javascript:

jQuery(document).ready(function() {
    offsetHeight = jQuery("#new-royalslider-1").height();
    offsetHeight = 0 - offsetHeight / 1.5;
    //console.log(offsetHeight);

    jQuery("p#floating-logo").css("margin-top", offsetHeight);
    //console.log(jQuery("p#floating-logo").css("margin-top"));

    $(window).resize(function() {
        offsetHeight = jQuery("#new-royalslider-1").height();
        offsetHeight = 0 - offsetHeight / 1.5;
        console.log(offsetHeight);

        jQuery("p#floating-logo").css("margin-top", offsetHeight);
        console.log(jQuery("p#floating-logo").css("margin-top"));
    })
});
4

1 に答える 1