简体   繁体   中英

Let a fixed div grow to width 100% by Click

I need some jquery support, because my js skills are very low ;(. I have found and modified a script, that slides a div out to the right (relative div), but the fixed div dont grow up to width 100% when the relative div slides out.

What´s the plan?

If I press "click here" the relative div should slide out and at the same time the fixed div should morph to width 100%. So if I press "Click here" again, the relative div slides back into his position and the fixed div should morph back to width 70% (same time).

Thats my script - can you modified it?

 $('#showmenu').click(function() {
            var $menu = $('.relative_div');
            if ($menu.is(':visible')) {
                // Slide away
                $menu.animate({right: -($menu.outerWidth() + 50)}, function() {
                    $menu.hide();
                });
            }
            else {
                // Slide in
                $menu.show().animate({right: 0});
            }
        });

FIDDLE

I would be very grateful.

Snatch

Just use

$('.fixed_div').animate({width: '100%'}); when you want to expand the div

and

$('.fixed_div').animate({width: '70%'}); when you want to short the div

DEMO

http://jsfiddle.net/efst0n17/4/

added

 $('.fixed_div').css("width","100%");

and

$('.fixed_div').css("width","70%");

Fixed for you!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM