8 Replies Latest reply on Jan 25, 2012 3:15 PM by Nancy OShea

    Parent div isn't expanding

    jed279

       

      If anyone has a free moment please have a look at this code and tell me why the #content div isn't expanding to include the child div's within it.
      Source code and style sheet below:

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

      <html xmlns="http://www.w3.org/1999/xhtml">

      <head>

      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

      <title>Index</title>

      <link href="global.css" rel="stylesheet" type="text/css" />

      </head>

       

       

      <body>

      <div id="container">

        <div id="header">

          <div id="logo"></div>

          <!-- end .header --></div>

      </div>

      <div id="content">

        <div id="pagetext">

          <h1>Instructions</h1>

          <p>Be aware that the CSS for these layouts is heavily commented. If you do most of your work in Design view, have a peek at the code to get tips on working with the CSS for the fixed layouts. You can remove these comments before you launch your site. To learn more about the techniques used in these CSS Layouts, read this article at Adobe's Developer Center - <a href="http://www.adobe.com/go/adc_css_layouts">http://www.adobe.com/go/adc_css_layouts</a>.</p>

          <h2>Clearing Method</h2>

          <p>Because all the columns are floated, this layout uses a clear:both declaration in the .footer rule.  This clearing technique forces the .container to understand where the columns end in order to show any borders or background colors you place on the .container. If your design requires you to remove the .footer from the .container, you'll need to use a different clearing method. The most reliable will be to add a &lt;br class=&quot;clearfloat&quot; /&gt; or &lt;div  class=&quot;clearfloat&quot;&gt;&lt;/div&gt; after your final floated column (but before the .container closes). This will have the same clearing effect.</p>

          <h3>Logo Replacement</h3>

          <p>An image placeholder was used in this layout in the .header where you'll likely want to place  a logo. It is recommended that you remove the placeholder and replace it with your own linked logo. </p>

          <p> </p>

        </div>

        <div id="sidebar1">

          <p> The above links demonstrate a basic navigational structure using an unordered list styled with CSS. Use this as a starting point and modify the properties to produce your own unique look. If you require flyout menus, create your own using a Spry menu, a menu widget from Adobe's Exchange or a variety of other javascript or CSS solutions.</p>

          <p>If you would like the navigation along the top, simply move the ul.nav to the top of the page and recreate the styling.</p>

          <!-- end .sidebar1 --></div>

        <div id="photobar">Content for  id "photobar" Goes Here</div>

        <!-- end .content --></div>

      <div id="footer">

        <p>This .footer contains the declaration position:relative; to give Internet Explorer 6 hasLayout for the .footer and cause it to clear correctly. If you're not required to support IE6, you may remove it.</p>

        <!-- end .footer --></div>

      </body>

      </html>

       

      @charset "UTF-8";

      /* CSS Document */

       

       

      body {

                background: #42413C repeat;

                margin: 0;

                padding: 0;

                color: #000;

                font-family: Verdana, Arial, Helvetica, sans-serif;

                font-size: 90%;

                line-height: 1.4;

      }

       

       

      /* ~~ Element/tag selectors ~~ */

      ul, ol, dl { /* Due to variations between browsers, it's best practices to zero padding and margin on lists# For consistency, you can either specify the amounts you want here, or on the list items (LI, DT, DD) they contain# Remember that what you do here will cascade to the #nav list unless you write a more specific selector# */

                padding: 0;

                margin: 0;

      }

      h1, h2, h3, h4, h5, h6, p {

                margin-top: 0;           /* removing the top margin gets around an issue where margins can escape from their containing div# The remaining bottom margin will hold it away from any elements that follow# */

                padding-right: 15px;

                padding-left: 15px; /* adding the padding to the sides of the elements within the divs, instead of the divs themselves, gets rid of any box model math# A nested div with side padding can also be used as an alternate method# */

      }

      a img { /* this selector removes the default blue border displayed in some browsers around an image when it is surrounded by a link */

                border: none;

      }

       

       

      /* ~~ Styling for your site's links must remain in this order - including the group of selectors that create the hover effect# ~~ */

      a:link {

                color: #42413C;

                text-decoration: underline; /* unless you style your links to look extremely unique, it's best to provide underlines for quick visual identification */

      }

      a:visited {

                color: #6E6C64;

                text-decoration: underline;

      }

      a:hover, a:active, a:focus { /* this group of selectors will give a keyboard navigator the same hover experience as the person using a mouse# */

                text-decoration: none;

      }

       

       

      /* ~~this fixed width container surrounds the other divs~~ */

      #container {

                width: 960px;

                background: #FFF;

                margin: 0 auto;

                /* [disabled]position: relative; */

                height: 150px;

      }

       

       

      /* ~~ the header is not given a width# It will extend the full width of your layout# It contains an image placeholder that should be replaced with your own linked logo ~~ */

      #header {

                background: #ccc;

                height: 152px;

      }

       

       

      #logo {

                position: relative;

                height: 460px;

                width: 300px;

                background: transparent url(../images/logo.png) no-repeat 0px 0px;

                top: 10px;

                float: right;

                /* [disabled]right: -650px; */

      }

      #content {

                padding: 10px 0;

                width: 960px;

                margin: 0 auto;

                background: #fff;

                /* [disabled]position: static; */

      }

       

       

      #pagetext {

                float: left;

                width: 600px;

      }

       

       

      */

      #sidebar1 {

                float: left;

                width: 300px;

                background: #EADCAE;

                /* [disabled]padding-bottom: 10px; */

                /* [disabled]margin-top: 320px; */

                /* [disabled]clear: left; */

                /* [disabled]margin-left: 60px; */

      }

       

       

      #photobar {

                clear: both;

                float: left;

                height: 50px;

                width: 100%;

                background: #666;

      }

       

       

      /* ~~ This grouped selector gives the lists in the #content area space ~~ */

      #content ul, #content ol {

                padding: 0 15px 15px 40px; /* this padding mirrors the right padding in the headings and paragraph rule above# Padding was placed on the bottom for space between other elements on the lists and on the left to create the indention# These may be adjusted as you wish# */

      }

       

       

      /* ~~ The navigation list styles (can be removed if you choose to use a premade flyout menu like Spry) ~~ */

      ul#nav {

                list-style: none; /* this removes the list marker */

                border-top: 1px solid #666; /* this creates the top border for the links - all others are placed using a bottom border on the LI */

                margin-bottom: 15px; /* this creates the space between the navigation on the content below */

      }

      ul#nav li {

                border-bottom: 1px solid #666; /* this creates the button separation */

      }

      ul#nav a, ul#nav a:visited { /* grouping these selectors makes sure that your links retain their button look even after being visited */

                padding: 5px 5px 5px 15px;

                display: block; /* this gives the link block properties causing it to fill the whole LI containing it# This causes the entire area to react to a mouse click# */

                width: 160px;  /*this width makes the entire button clickable for IE6# If you don't need to support IE6, it can be removed# Calculate the proper width by subtracting the padding on this link from the width of your sidebar container# */

                text-decoration: none;

                background: #C6D580;

      }

      ul#nav a:hover, ul#nav a:active, ul#nav a:focus { /* this changes the background and text color for both mouse and keyboard navigators */

                background: #ADB96E;

                color: #FFF;

      }

       

       

      /* ~~ The footer ~~ */

      #footer {

                padding: 10px 0;

                background: #FF0;

                position: relative;/* this gives IE6 hasLayout to properly clear */

                clear: both; /* this clear property forces the .container to understand where the columns end and contain them */

      }

       

       

      /* ~~ miscellaneous float/clear classes ~~ */

      .fltrt {  /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */

                float: right;

                margin-left: 8px;

      }

      .fltlft { /* this class can be used to float an element left in your page. The floated element must precede the element it should be next to on the page. */

                float: left;

                margin-right: 8px;

      }

      .clearfloat { /* this class can be placed on a <br /> or empty div as the final element following the last floated div (within the #container) if the #footer is removed or taken out of the #container */

                clear:both;

                height:0;

                font-size: 1px;

                line-height: 0px;

      }

       

        • 1. Re: Parent div isn't expanding
          MurraySummers Level 8

          Change this -

           

          #content {

                    padding: 10px 0;

                    width: 960px;

                    margin: 0 auto;

                    background: #fff;

                    /* [disabled]position: static; */

          }

           

          to this -

           

          #content {

                    padding: 10px 0;

                    width: 960px;

                    margin: 0 auto;

                    background: #fff;

                    overflow:hidden;

          }

          • 2. Re: Parent div isn't expanding
            martcol Level 4

            Try adding

             

            overflow: hidden

             

            To the #container rule

            1 person found this helpful
            • 3. Re: Parent div isn't expanding
              Nancy OShea Adobe Community Professional & MVP

              Did you clear your floats?  When floats are no longer needed, you must clear them to bring the following content back into the normal document flow.  One method is to use a paragraph or HR tag with a clearing class.

               

              .clearing {

                   clear:both;

                   display:block;

                   visibility:hidden;

              }

               

              Another popular method is overflow:hidden applied to the parent container.

               

              #content {

                        padding: 10px 0;

                        width: 960px;

                        margin: 0 auto;

                        background: #fff;

                        /* [disabled]position: static; */

              }

               

              To this:

               

              #content {

                        padding: 10px 0;

                        width: 960px;

                        margin: 0 auto;

                        background: #fff;

                        overflow:hidden /**float containment**/

              }

               

              To learn more about why this works so well,  see below:

              http://colinaarts.com/articles/the-magic-of-overflow-hidden/

               

               

               

              Nancy O.

              Alt-Web Design & Publishing

              Web | Graphics | Print | Media  Specialists 

              http://alt-web.com/

              http://twitter.com/altweb

              1 person found this helpful
              • 4. Re: Parent div isn't expanding
                jed279 Level 1

                Thanks! I was hoping I was simply overlooking something.

                • 5. Re: Parent div isn't expanding
                  martcol Level 4

                  Oops!  I meant #content.

                  • 6. Re: Parent div isn't expanding
                    jed279 Level 1

                    Looks like there's another small problem. The #logo div is pushing the #content div down. I want the #logo div to overlap the #content div. Any suggestions?

                    • 7. Re: Parent div isn't expanding
                      MurraySummers Level 8

                      Make #header have position:relative, and #logo have position:absolute.  Then place it where you want it.

                      1 person found this helpful
                      • 8. Re: Parent div isn't expanding
                        Nancy OShea Adobe Community Professional & MVP

                        Change this:

                         

                        #container {

                                  width: 960px;

                                  background: #FFF;

                                  margin: 0 auto;

                                  /* [disabled]position: relative; */

                                  height: 150px;

                        }

                         

                        To this:

                         

                        #container {

                                  width: 960px;

                                  background: #FFF;

                                  margin: 0 auto;

                                  position:relative; /**to control APDivs**/

                        }

                         

                        Change this:

                         

                        #logo {

                                  position: relative;

                                  height: 460px;

                                  width: 300px;

                                  background: transparent url(../images/logo.png) no-repeat 0px 0px;

                                  top: 10px;

                                  float: right;

                                  /* [disabled]right: -650px; */

                        }

                         

                        to this:

                         

                        #logo {

                             position:absolute:

                             top:xxpx; /**adjust as required**/

                             left:xxpx; /**adjust as required**/

                             z-index:100;

                             height: 460px;

                             width: 300px;

                             background-image:url(../images/logo.png);

                        }

                         

                        And add this to your #content.

                         

                        #content {

                             position:relative:

                             z-index:1;

                        }

                         

                         

                        Nancy O.

                        Alt-Web Design & Publishing

                        Web | Graphics | Print | Media  Specialists 

                        http://alt-web.com/

                        http://twitter.com/altweb

                        1 person found this helpful