jquery accordion auto adjust bar

I have this code:

http://jsbin.com/ETESUqA/6/edit

I have 2 questions:
1.-How can I do to the blue background auto expand to the width of the browser automatic no needed to do in the height. This auto width must not affect the size and position of the accordion.
2.-How can I make to return to original state of the color green of the tabs if you close all tabs because if you see if you close all tabs the last tab opened stay on gray. In other words if all the tabs closed after navigate on any tab all the tabs must have the color green of original state.
Tried to move something in CSS but I just messes the colors.
Thank you
coerraceAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott FellDeveloper & EE ModeratorCommented:
1) Width of blue background full width.

Change the width of the accordion to 100% AND get rid of all the inline css and place that in your external css.  At the same time, make sure the outer tags do not limit to a specific width.
    #accordion {
        padding: 10px 100px 10px 100px;
      width: 100%;
        background-color: blue;
      
    }
You will need to play with this more but this is the idea http://jsbin.com/ETESUqA/11/edit
 
<div style="height:170px;">
        <h3 class="docs">Drag bottom right corner to resize</h3>
     
    <h2>    </h2>
        <div id="accordion">
            <h3>Section 1</h3>
            <div>
                <p>Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.</p>
            </div>
            <h3>Section 2</h3>
            <div>
                <p>Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In suscipit faucibus urna. </p>
            </div>
            <h3>Section 3</h3>
            <div>
                <p>Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis. Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quis lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui. </p>
                <ul>
                    <li>List item one</li>
                    <li>List item two</li>
                    <li>List item three</li>
                </ul>
            </div>
            <h3>Section 4</h3>
            <div>
                <p>Cras dictum. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia mauris vel est. </p><p>Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. </p>
            </div>
        </div>
 
</div>
 
</div>
 
</body>
</html>
 

Open in new window

coerraceAuthor Commented:
ok I tested but I if you noted doing that the problem at least here is that grow everything width including the green area the green tabs must not be affected is just the blue area.
By your side you look just width the blue area?
Scott FellDeveloper & EE ModeratorCommented:
Ok, I added an accordion wrapper http://jsbin.com/ETESUqA/19/edit?html,css,output

Please double check your html.  You had either an extra closing div just under

<div style="position:absolute;left:28px;top:396px;width:885px;height:196px;">

or at the bottom, I assumed it was at the bottom.  


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Home</title><meta name="viewport" content="width=990">
  
    <script src="http://code.jquery.com/jquery-1.8.2.js"></script>
    <script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>
    
    <style>
    #accordion-resizer {
        padding: 10px;
        width: 350px;
        height: 500px;
        background-color: red;

	
    }

    #accordion {
        padding: 10px 100px 10px 100px;
	width: 150px;
      
	
    }
      #accordion_wapper{
        background-color:blue;
        width:100%;
        
        
      }
        html { overflow-x: hidden; }
    h2 { 
      background: black;
      color: white;
      padding: 10px 0;
      position: relative;
    }
    h2:before, h2:after {
      content: "";
      background: black;
      position: absolute;
      top: 0;
      bottom: 0;
      width: 9999px;
    }
    h2:before {
      right: 100%;
    }
    h2:after {
      left: 100%;
    }
    
    h2:nth-of-type(1), h2:nth-of-type(1):before, h2:nth-of-type(1):after { background: #dc4916; }
    h2:nth-of-type(2), h2:nth-of-type(2):before, h2:nth-of-type(2):after { background: #6871b1; }
    h2:nth-of-type(3), h2:nth-of-type(3):before, h2:nth-of-type(3):after { background: #d1b935; }
    
    .left-only:after {
      display: none;
    }
    
    .right-only:before {
      width: 20px;
    }
    </style>
    <script>
    $(function() {
        $( "#accordion" ).accordion({
 	   autoHeight: false,
           heightStyle: "content",
           active: false,
           collapsible: true

        });
    });
    $(function() {
        $( "#accordion-resizer" ).resizable({
            minHeight: 140,
            minWidth: 200,
            resize: function() {
                $( "#accordion" ).accordion( "refresh" );
            }
        });
    });
    </script>
<style type="text/css">
body{margin:0;padding:0;}
</style>
</head>

<body text="#000000" style="background:#ffffff; height:1000px;">
<div style="background-color:#808000;">
<div style="position:absolute;left:28px;top:396px;width:885px;height:196px;">
    
</div>

<div style="height:170px;">
        <h3 class="docs">Drag bottom right corner to resize</h3>
     
    <h2>    </h2>
    <div id="accordion_wapper">
        <div id="accordion">
            <h3>Section 1</h3>
            <div>
                <p>Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.</p>
            </div>
            <h3>Section 2</h3>
            <div>
                <p>Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In suscipit faucibus urna. </p>
            </div>
            <h3>Section 3</h3>
            <div>
                <p>Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis. Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quis lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui. </p>
                <ul>
                    <li>List item one</li>
                    <li>List item two</li>
                    <li>List item three</li>
                </ul>
            </div>
            <h3>Section 4</h3>
            <div>
                <p>Cras dictum. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia mauris vel est. </p><p>Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. </p>
            </div>
        </div>

</div>
  </div>


</body>
</html>

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
coerraceAuthor Commented:
Works very good thank you.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.