문제

How can I make my already existing checkout cart float/follow as i scroll (having the table minimized to save screen space and maximize when clicked if possible would be amazing)

Also, if you could help me with making it magically appear at a certain point in the page, that would definitely be appreciated.

Any help would be great!!!

Current format: http://i265.photobucket.com/albums/ii208/dentyne_fire/untitled_zps88f72bf0.jpg

Code goes as follows:

Cart Div:

     <div id="sidebar">
            <h2>Your Cart</h2>


            <!--Add a Div with the class "simpleCart_items" to show your shopping cart area.-->
            <div class="simpleCart_items" >
            </div>


            <!--Here's the Links to Checkout and Empty Cart-->
            <a href="#" class="simpleCart_empty"><font color="#f5d700">empty cart</font></a>
            <a href="#" class="simpleCart_checkout">Checkout</a>



            <!--Nothing below this has to do with simpleCart (js) functionality-->

        <!--End #sidebar--> 
</div>

Cart CSS:

         <style>

    .cartHeaders,.totalRow{display:none;}
    .simpleCart_items{
        overflow-y:auto;
        overflow-x:hidden;
        height:324px;
        width:243px;
        margin-bottom:20px;

    }
    .itemContainer{
        clear:both;
        width:229px;
        padding:11px 0;
        font-size:11px;
    }
    .itemImage{
        float:left;
        width:60px;
    }
    .itemName{
        float:left;
        width:85px;
    }
    .itemPrice{
        float:left;
        width:85px;
        color:#418932;
    }
    .itemQuantity{
        float:left;
        width:33px;
        margin-top:-12px;
        vertical-align:middle;
    }
    .itemQuantity input{
        width:20px;
        border:1px solid #ccc;
        padding:3px 2px;
    }

    .itemTotal{
        float:left;
        color:#c23f26;
        margin-top:-6px
    }
</style>
도움이 되었습니까?

해결책

We can't help you making things we can only help you correct things you couldn't manage to do on your own.

What you should do is write a little piece of JavaScript which will check if the user has passed a certain point on your page, you can do that with the onScroll event and with the offsetheight.

If the user is passed the point then apply the class fixed to your checkout, if not then remove the class (don't forget this, users tend to scroll up as well). Next create a fixed CSS class and make sure the cart is positioned correctly on the screen.

Good luck

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top