Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4
  1. #1
    Junior Member
    Join Date
    Jul 2010
    Posts
    2
    Member #
    22638
    Hey guys, can't get my divs to sit right and i've been playing around for ages trying to do something simple. It's just a wireframe template at the minute so it's quite annoying to have this problem.

    Basically I have all my divs inside a container, there's a header, sidebar, content and footer. The problem i'm having is that everything is displaying in the rough correct location (header on top, sidebar to the left side), main content in the middle and the footer at the bottom but the main content only begins BELOW the sidebar and I can't get it to appear right under the header beside the sidebar. Code is below. Perhaps even more worryingly the sidebar is current set to "float: none;" in the CSS and when I set it to "float: left;" which surely it should, it all moves to the right hand side and overlaps with the header.

    Code:
    <!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" />
    <!-- TemplateBeginEditable name="doctitle" -->
    <title>SITE TITLE</title>
    <!-- TemplateEndEditable -->
    <!-- TemplateBeginEditable name="head" -->
    <!-- TemplateEndEditable -->
    <link href="stylesheet.css" rel="stylesheet" type="text/css" /><!--[if IE 5]>
    <style type="text/css"> 
    /* place css box model fixes for IE 5* in this conditional comment */
    .twoColFixLtHdr #sidebar1 { width: 200px; }
    </style>
    <![endif]--><!--[if IE]>
    <style type="text/css"> 
    /* place css fixes for all versions of IE in this conditional comment */
    .twoColFixLtHdr #sidebar1 { padding-top: 30px; }
    .twoColFixLtHdr #mainContent { zoom: 1; }
    /* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */
    </style>
    <![endif]-->
    <script src="Scripts/swfobject_modified.js" type="text/javascript"></script>
    <SCRIPT TYPE="text/javascript">
    <!--
    // copyright 1999 Idocs, Inc. http://www.idocs.com/tags/
    // Distribute this script freely, but please keep this 
    // notice with the code.
    
    var rollOverArr=new Array();
    function setrollover(OverImgSrc,pageImageName)
    {
    if (! document.images)return;
    if (pageImageName == null)
        pageImageName = document.images[document.images.length-1].name;
    rollOverArr[pageImageName]=new Object;
    rollOverArr[pageImageName].overImg = new Image;
    rollOverArr[pageImageName].overImg.src=OverImgSrc;
    }
    
    function rollover(pageImageName)
    {
    if (! document.images)return;
    if (! rollOverArr[pageImageName])return;
    if (! rollOverArr[pageImageName].outImg)
        {
        rollOverArr[pageImageName].outImg = new Image;
        rollOverArr[pageImageName].outImg.src = document.images[pageImageName].src;
        }
    document.images[pageImageName].src=rollOverArr[pageImageName].overImg.src;
    }
    
    function rollout(pageImageName)
    {
    if (! document.images)return;
    if (! rollOverArr[pageImageName])return;
    document.images[pageImageName].src=rollOverArr[pageImageName].outImg.src;
    }
    //-->
    </SCRIPT>
    <SCRIPT TYPE="text/javascript">
    <!--
    setrollover('homer.png',   'home');
    setrollover('diariesr.png', 'diaries');
    setrollover('calendarsr.png',	'calendars');
    setrollover('pensr.png',	'pens');
    setrollover('ataglancer.png',	'ataglance');
    setrollover('contactr.png',  'contact');
    //-->
    </SCRIPT>
    
    
    </head>
    
    <body class="twoColFixLtHdr">
    
    <div id="container">
      <div id="header">
        <img src="banner.png" width="800px" height="120px" border="0" align="left" usemap="#Map""100px" />
        <map name="Map" id="Map">
          <area shape="rect" coords="619,92,785,106" href="EMAIL" alt="Email us" />
          <area shape="rect" coords="618,107,785,118" href="SITE" alt="Visit our site" />
    
          <area shape="rect" coords="619,52,736,66" href="PHONE" alt="Skype call" />
          <area shape="rect" coords="617,1,769,43" href="GOOGLEMAPS" target="_blank" alt="View our factory on Google Maps" />
        </map>
      <!-- end #header --></div>
      <div id="sidebar1">
      	<a href="index.html" onMouseOver="rollover('home')" onMouseOut="rollout('home')">
        <img src="home.png" name="home" alt="Home Page" align="left" width="200px" height="30px" border="0" /></a>
        <a href="diaries.html" onMouseOver="rollover('diaries')" onMouseOut="rollout('diaries')">
        <img src="diaries.png" name="diaries" alt="Diaries" align="left" width="200px" height="30px" border="0" /></a>
    
        <a href="calendars.png" onMouseOver="rollover('calendars')" onMouseOut="rollout('calendars')">
        <img src="calendars.png" name="calendars" alt="Calendars" align="left" width="200px" height="30px" border="0" /></a>
        <a href="pens.png" onMouseOver="rollover('pens')" onMouseOut="rollout('pens')">
        <img src="pens.png" name="pens" alt="Pens" align="left" width="200px" height="30px" border="0" /></a>
        <a href="ataglance.png" onMouseOver="rollover('ataglance')" onMouseOut="rollout('ataglance')">
        <img src="ataglance.png" name="ataglance" alt="All at a glance" align="left" width="200px" height="30px" border="0" /></a>
        <a href="contact.html" onMouseOver="rollover('contact')" onMouseOut ="rollout('contact')">
        <img src="contact.png" name="contact" alt="Home Page" height="30px" width="200px" border="0" /></a>
    
      <!-- end #sidebar1 --></div>
      <div id="mainContent">
        <p>Content</p>
        <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="600" height="440" id="FlashID" title="Interactive">
          <param name="movie" value="ecoflip.swf" />
          <param name="quality" value="high" />
          <param name="wmode" value="opaque" />
          <param name="swfversion" value="8.0.35.0" />
          <!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you donít want users to see the prompt. -->
    
          <param name="expressinstall" value="Scripts/expressInstall.swf" />
          <!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->
          <!--[if !IE]>-->
          <object type="application/x-shockwave-flash" data="ecoflip.swf" width="600" height="440">
            <!--<![endif]-->
            <param name="quality" value="high" />
            <param name="wmode" value="opaque" />
            <param name="swfversion" value="8.0.35.0" />
            <param name="expressinstall" value="Scripts/expressInstall.swf" />
    
            <!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->
            <div>
              <h4>Content on this page requires a newer version of Adobe Flash Player.</h4>
              <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p>
            </div>
            <!--[if !IE]>-->
          </object>
          <!--<![endif]-->
    
        </object>
      </div>
    	<!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats --><br class="clearfloat" />
      <div id="footer">
        <p>&copy; 2010 - Website design by <a href="mailto:kylemyers@live.co.uk">Kyle Myers</a></p>
      <!-- end #footer --></div>
    <!-- end #container --></div>
    <script type="text/javascript">
    <!--
    swfobject.registerObject("FlashID");
    //-->
    
    </script>
    </body>
    </html>
    Code:
    @charset "utf-8";
    body  {
    	font: 100% Verdana, Arial, Helvetica, sans-serif;
    	background: #EEDFCC;
    	margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
    	padding: 0;
    	text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
    	color: #000000;
    }
    
    li {
    color: #B22222;
    }
    li span {
    color: #000000;
    }
    
    .twoColFixLtHdr #container { 
    	width: 80%;  /* using 20px less than a full 800px width allows for browser chrome and avoids a horizontal scroll bar */
    	background: #FFFFFF;
    	margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
    	border: 1px solid #000000;
    	text-align: left; /* this overrides the text-align: center on the body element. */
    } 
    .twoColFixLtHdr #header { 
    	background: #FFFFFF;
    	padding: 0 0 0 0;  /* this padding matches the left alignment of the elements in the divs that appear beneath it. If an image is used in the #header instead of text, you may want to remove the padding. */
    } 
    .twoColFixLtHdr #header h1 {
    	margin: 0; /* zeroing the margin of the last element in the #header div will avoid margin collapse - an unexplainable space between divs. If the div has a border around it, this is not necessary as that also avoids the margin collapse */
    	padding: 10px 0; /* using padding instead of margin will allow you to keep the element away from the edges of the div */
    }
    .twoColFixLtHdr #sidebar1 {
    	float: none; /* since this element is floated, a width must be given */
    	width: 200px; /* the actual width of this div, in standards-compliant browsers, or standards mode in Internet Explorer will include the padding and border in addition to the width */
    	background: #015b1a; /* the background color will be displayed for the length of the content in the column, but no further */
    	padding: 120px 0px 0px 0px;
    }
    .twoColFixLtHdr #mainContent { 
    	margin: 0 0 0 220px; /* the left margin on this div element creates the column down the left side of the page - no matter how much content the sidebar1 div contains, the column space will remain. You can remove this margin if you want the #mainContent div's text to fill the #sidebar1 space when the content in #sidebar1 ends. */
    	padding: 0 0 0 0; /* remember that padding is the space inside the div box and margin is the space outside the div box */
    } 
    .twoColFixLtHdr #footer { 
    	padding: 0 10px 0 20px; /* this padding matches the left alignment of the elements in the divs that appear above it. */
    	background:#DDDDDD; 
    } 
    .twoColFixLtHdr #footer p {
    	margin: 0; /* zeroing the margins of the first element in the footer will avoid the possibility of margin collapse - a space between divs */
    	padding: 10px 0; /* padding on this element will create space, just as the the margin would have, without the margin collapse issue */
    }
    .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 */
    	float: left;
    	margin-right: 8px;
    }
    .clearfloat { /* this class should be placed on a div or break element and should be the final element before the close of a container that should fully contain a float */
    	clear:both;
        height:0;
        font-size: 1px;
        line-height: 0px;
    }
    Any help would be appreciated... I know it's something stupid i'm missing.

  2.  

  3. #2
    Senior Member aeroweb99's Avatar
    Join Date
    Feb 2008
    Location
    Port Huron, Michigan
    Posts
    1,037
    Member #
    16468
    Liked
    1 times
    Can you upload this somewhere please??? It's going to be a width problem somewhere, and I noticed you changed some things with that DW template, namely the sidebar float and some widths too. But most of us don't have time to load everything up and troubleshoot.

  4. #3
    Junior Member
    Join Date
    Jul 2010
    Posts
    2
    Member #
    22638
    Hey there,

    I changed the float and things while I was experimenting trying to get it to work. I managed to fix the problem myself today. I'd given the sidebar div a width which means it doesn't float correctly. All I had to do was remove the width and reapply the left float and it slotted in nicely.

    I'll keep the uploading in mind if I need help in the future. Thanks.

  5. #4
    Senior Member aeroweb99's Avatar
    Join Date
    Feb 2008
    Location
    Port Huron, Michigan
    Posts
    1,037
    Member #
    16468
    Liked
    1 times
    Floats actually need a width, to be semantically correct and to control it. Just make sure you calculate your widths with padding, borders, and margins too so they will fit in the parent container.

    Read this little tidbit about half way down it tells why.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Search tags for this page

i have a div floated right but the next div sits below

,

sidebar sitting below body float

,

website content below sidebar

Click on a term to search for related topics.
All times are GMT -6. The time now is 08:10 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com