Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7704745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:45:00+00:00 2026-05-31T23:45:00+00:00

I have 2 divs, 70% and 30% widths, within a 100% width containing div.

  • 0

I have 2 divs, 70% and 30% widths, within a 100% width containing div. On click I want the 70% div to change to 100% width and ‘slide over’ the 30% div and on second click retract back to 70% and reinstate the 30% div. I’ve half achieved the desired effect below; it ‘slides over’ the smaller div but retains it’s 70% width. I can’t get the width to expand to 100% without having a stutter animation as I’ve invoked the width change after the toggle or it expanding to 100% but the other 30% div still being visible and knocking the divs onto 2 lines.

http://jsfiddle.net/establish/scKf2/

I did see another similar question that works but they are static widths and I couldn’t successfully convert them into percentages without the above problems cropping up again.

http://jsfiddle.net/establish/kjDYh/

HTML

<div id='ember'>

<div id='sidebar'>
</div>

<div id='activity'>
    <a href='#' id='trigger'>Nav</a>
</div>

</div>

CSS

#sidebar { 
background-color: green; 
float: left;
height: 200px;
position: relative;
z-index: 5;
width: 30%;
}

#activity { 
background-color: purple; 
float: left;
height: 200px;
position: relative;
z-index: 10;
width: 70%;
}

a { 
color: white;
display: block; 
padding: 12px; 
text-decoration: none;
}

JS – First Attempt

$('#trigger').click(function() {

$('#sidebar').animate({width: 'toggle'});

});​

JS – Second Attempt

$('#trigger').toggle(function() {
    $('#sidebar').animate({width: '+=22em'});
    $('#activity').animate({width: '-=22em'});
},function() {
    $('#sidebar').animate({width: '-=22em'});
    $('#activity').animate({width: '+=22em'});
});​

​

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T23:45:01+00:00Added an answer on May 31, 2026 at 11:45 pm

    You can do something like this?

    http://jsfiddle.net/kjDYh/2/

    basically set the nav to 0px and main to 100%?

    $('#trigger').toggle(function() {
        $('#sidebar').animate({width: '100%'});
        $('#activity').animate({width: '0px'});
    },function() {
        $('#sidebar').animate({width: '70%'});
        $('#activity').animate({width: '30%'});
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large DIV of 586px width. Within this are two smaller DIVs,
I have a fluid width container DIV. Within this I have 4 DIVs all
If you have two divs contained within a div: <div style=border:1px;> <div style=float:left;background-color:red;width:20px;height:20px;> <div
I have a load of fixed width divs inside a dynamic width div. The
Have three divs in a container that I want to float over a large
Say I have a div container with multiple divs with some width and height.
I have 4 divs set to float:left; each with a width: 400px; within a
I have 2 divs (myDiv1 and myDiv2) that is located within another div (otherDiv)
I have a div with a certain width and within this parent div I
I have a container div that holds two internal divs; both should take 100%

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.