admin管理员组

文章数量:1352849

I would like to be able to change the width of my div using the mousewheel.
I guess this is very hard to do (at least to hard for me), but I thought maybe someone has ever written such a jquery or javascript code.

To put in some context: here is the relevant part of my website: /
And here is the plete website. I would like the user to decide how big the #main div is going to be.

I would like to be able to change the width of my div using the mousewheel.
I guess this is very hard to do (at least to hard for me), but I thought maybe someone has ever written such a jquery or javascript code.

To put in some context: here is the relevant part of my website: http://jsfiddle/XGERP/1/
And here is the plete website. I would like the user to decide how big the #main div is going to be.

Share Improve this question asked Jun 24, 2013 at 19:45 90intuition90intuition 9963 gold badges12 silver badges25 bronze badges 0
Add a ment  | 

2 Answers 2

Reset to default 8

Here's some jquery to tickle your fancy. Tested to work in Chrome, Firefox, and IE11.

$(document).ready(function(){
    $('#main').bind('wheel mousewheel', function(e){
        var delta;

        if (e.originalEvent.wheelDelta !== undefined)
            delta = e.originalEvent.wheelDelta;
        else
            delta = e.originalEvent.deltaY * -1;

            if(delta > 0) {
                $("#main").css("width", "+=10");
            }
            else{
                $("#main").css("width", "-=10");
            }
        });
    });

You could use Jquery Zoom...

http://www.jacklmoore./zoom/

Then just as the user hovers, they can read a bit closer...

Not sure if it would work with text though, haven't really looked into it

Or you could do something like this...

 $('#main').mousewheel(function(event, delta) {
var delta_px = delta > 0 ? "+=50" : "-=50";
$(this).css('width', delta_px);
});

You need the mousewheel extension plugin for that...

http://archive.plugins.jquery./project/mousewheel

Heres a working demo, the mousewheel script is above everything, then the actual jquery you want is at the bottom

DEMO HERE

本文标签: javascriptjquery mousewheel zoom (changing width of div)Stack Overflow