RobVious
RobVious

Reputation: 12915

Implementing vertical scroll with css and javascript? (with fiddle)

Here's my fiddle:

http://jsfiddle.net/PTSkR/93/

I have an unordered list of items that can be scrolled through.

I'm trying to work out which approach is best:

  1. Use CSS / jquery to set overflow to hidden and move the position of the <ul>

What's the best way to do this?

Code:

<div class="span4 side-study-box">
            <div class="side-box-menu">
                <a class ="side-box-menu-nav"><i class="icon-chevron-up icon-white"></i></a>
                <ul>
                    <li>
                        <a class="side-box-menu-control"><i class="icon-facetime-video "></i></a>
                    </li>
                    <li>
                        <a class="side-box-menu-control"><i class="icon-picture"></i></a>
                    </li>
                    <li>
                        <a class="side-box-menu-control"><i class="icon-headphones "></i></a>
                    </li>
                    <li>
                        <a class="side-box-menu-control"><i class="icon-pencil "></i></a>
                    </li>
                    <li>
                        <a class="side-box-menu-control"><i class="icon-hdd"></i></a>
                        <!-- Need code, math, sound, url, text -->
                    </li>
                </ul>
                <a class ="side-box-menu-nav"><i class="icon-chevron-down icon-white"></i></a>
            </div>

        </div>

Upvotes: 1

Views: 585

Answers (1)

Kieran
Kieran

Reputation: 18049

what about this: http://jsfiddle.net/PTSkR/94/

you need to add some type of click binding to move the menu up or down and a view port to limit the size

There are so many options when animating this is a really simple example that works only once. click binding would be like

$('.down').click(function () {
    var $move = $('.side-study-box ul');
    $move.css({
        top: '-20px'
    })
})

To get the elements posistion using jquery try

var position = $move.position();

Upvotes: 1

Related Questions