Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Sep 2006
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need help removing big gap

    In the example code below, there is a large gap at the bottom of the page. I'm speaking of the white space between the blue box and the end of the page. I understand why it's there, but I need a way to get rid of it.

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    
    <html>
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
      <title>Untitled Document</title>
    <style type="text/css">
    
    #wrap {
      width: 760px;
      margin: auto;
    }
    
    #box1 {
      background: #000;
      width: 100%;
      height: 400px;
    }
    
    #box2 {
      background: #0000ff;
      width: 100%;
      height: 200px;
    }
    
    #box3 {
      background: #ff0000;
      width: 300px;
      height: 300px;
      position: relative;
      top: -200px;
      left: -50px;
      float: left;
    }
    
    </style>
    </head>
    
    <body>
      <div id="wrap">
        <div id="box1"></div>
        <div id="box2">
    	    <div id="box3"></div>
    		</div>
      </div>
    </body>
    </html>

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    This is normal. Relatively positioned elements occupy the space they were originally in. Why are you using relative positioning in the first place? Just use margins. Don't abuse positioning. Its exactly what you are doing.
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

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