Results 1 to 9 of 9

Thread: Help: How do I stack my div boxes?

  1. #1
    aka .:iGi:. Calcutter DannyM's Avatar
    Join Date
    Feb 2007
    Location
    Location Location!
    Posts
    915
    Thanks
    111
    Thanked
    125 times in 97 posts
    • DannyM's system
      • Motherboard:
      • Gigabyte Z68MA-D2H-B3
      • CPU:
      • Intel Core i5-2400
      • Memory:
      • 8GB Corsair Vengeance DDR3 - PC-12800
      • Storage:
      • 120GB A-Data SSD
      • Graphics card(s):
      • 1GB Nvidia ASUS 560Ti DirectuII
      • PSU:
      • Corsair 620W HX Modular PSU
      • Case:
      • Fractal Design Define Mini
      • Operating System:
      • Windows 7 Pro 64bit
      • Monitor(s):
      • 23" Dell UltraSharp U2311H
      • Internet:
      • 50Mb Virgin Media Cable Broadband

    Help: How do I stack my div boxes?

    Evening folks,

    I'm doing a website for a module at Uni and I'm having a little trouble just now. I'm trying to create a separate div for my left navigation that goes above the box to create a little login section, however, this happens when I try to add it:



    I tried:

    Code:
    clear: both
    But that just does this (see right):



    My CSS for my "leftnav" section:

    Code:
    /* Left Nav */
    
    
    
    #leftnav {
    
    	padding: 0;
    
    	background: #DDD;
    
    	margin: 0 0 0 10px;
    
    	min-height: 50px;
    
    	height: 100%;
    
    	border: 1px solid #999;
    
    	float: left; 
    
    	width: 180px;
    
    }
    
    
    
    #leftnavlogin {
    
    	padding: 0;
    
    	background: #DDD;
    	
    	margin: 10px 0 0 10px;
    
    	min-height: 50px;
    
    	height: 100%;
    
    	border: 1px solid #999;
    
    	float: left; 
    
    	width: 180px;
    	
    	clear: both;
    
    }
    
    
    
    div.leftnavcontainer {
    
    	margin: 10px 10px 10px 10px;
    
    	background: #f4f4f4;
    
    	height: 100%;
    
    }
    My leftnav.php file:

    Code:
    	<!-- Left column Section -->
    
    
    
        <div id="leftnav">
        
            <div class="leftnavcontainer">
            
            <form name="search" action="search.php" method="get" class="form1">
              
                    <span class="leftnav">Search</span>
                    <table>
    
                            <tr valign="top">
                           
                            <td align="left"><input type="text" name="searchTitle" title="Search for news articles" id="searchTitle" size="18" /></td>
    
                        </tr>
                        
                            <tr valign="top">
    
                            <td align="left"> <input type="submit" name="submit" id="submit" value="Submit" />
    
                            </td>
    
                        </tr>
    
                    </table>
    
            </form>
    
              <p class="leftnav">Quick-Links</p>
    
                <ul id="leftnavlist">
    
                    <li><a href="index.php">News</a></li>
    
                    <li><a href="./results.html">Results</a></li>
    
                    <li><a href="./fixtures.html">Fixtures</a></li>
    
                    <li><a href="./squad.html">Squad</a></li>
    
                    <li><a href="./images.html">Images</a></li>
    
                    <li><a href="./video.html">Video</a></li>
    
                </ul><br />
    
            </div>
            
        </div>
        
        <div id="leftnavlogin">
    		
            <div class="leftnavcontainer">
            
            <p>Login BOX</p>
        
        	</div>
            
        </div>
    Apologies for any 'noobness' but asides from just starting the whole layout again, I'm a little lost just now.

    Thanks for any help

  2. #2
    Senior Member
    Join Date
    Jul 2004
    Location
    London
    Posts
    2,456
    Thanks
    100
    Thanked
    75 times in 51 posts
    • Mblaster's system
      • Motherboard:
      • ASUS PK5 Premium
      • CPU:
      • Intel i5 2500K
      • Memory:
      • 8gb DDR3
      • Storage:
      • Intel X25 SSD + WD 2TB HDD
      • Graphics card(s):
      • Nvidia GeForce GTX 570
      • PSU:
      • Corsair HX520
      • Case:
      • Antec P180
      • Operating System:
      • Windows 7 Professional x64
      • Monitor(s):
      • HP w2207 (22" wide)
      • Internet:
      • Rubbish ADSL

    Re: Help: How do I stack my div boxes?

    Ummm, move the 'leftnavlogin' div to before the 'leftnav' div in the HTML!

    I'm assuming you want to get what you have in the second screenshot, but with the login box above the navigation.
    I don't mean to sound cold, or cruel, or vicious, but I am so that's the way it comes out.

  3. #3
    aka .:iGi:. Calcutter DannyM's Avatar
    Join Date
    Feb 2007
    Location
    Location Location!
    Posts
    915
    Thanks
    111
    Thanked
    125 times in 97 posts
    • DannyM's system
      • Motherboard:
      • Gigabyte Z68MA-D2H-B3
      • CPU:
      • Intel Core i5-2400
      • Memory:
      • 8GB Corsair Vengeance DDR3 - PC-12800
      • Storage:
      • 120GB A-Data SSD
      • Graphics card(s):
      • 1GB Nvidia ASUS 560Ti DirectuII
      • PSU:
      • Corsair 620W HX Modular PSU
      • Case:
      • Fractal Design Define Mini
      • Operating System:
      • Windows 7 Pro 64bit
      • Monitor(s):
      • 23" Dell UltraSharp U2311H
      • Internet:
      • 50Mb Virgin Media Cable Broadband

    Re: Help: How do I stack my div boxes?

    Quote Originally Posted by Mblaster View Post
    Ummm, move the 'leftnavlogin' div to before the 'leftnav' div in the HTML!

    I'm assuming you want to get what you have in the second screenshot, but with the login box above the navigation.
    Yes I do, but I want the rightnav bit to be inline with the top of the middle and leftnav if that makes sense?

  4. #4
    Not a good person scaryjim's Avatar
    Join Date
    Jan 2009
    Location
    Gateshead
    Posts
    15,196
    Thanks
    1,231
    Thanked
    2,291 times in 1,874 posts
    • scaryjim's system
      • Motherboard:
      • Dell Inspiron
      • CPU:
      • Core i5 8250U
      • Memory:
      • 2x 4GB DDR4 2666
      • Storage:
      • 128GB M.2 SSD + 1TB HDD
      • Graphics card(s):
      • Radeon R5 230
      • PSU:
      • Battery/Dell brick
      • Case:
      • Dell Inspiron 5570
      • Operating System:
      • Windows 10
      • Monitor(s):
      • 15" 1080p laptop panel

    Re: Help: How do I stack my div boxes?

    The positioning of floats is complex in HTML and not particularly consistently implemented either!! The best way of acheiving what you're after is not to have both the leftnav and login boxes floating, but to put them both in a containing div that is floating - so you'd have something like:
    Code:
    #leftnavcontainer { float: left; }
    in your CSS and
    Code:
    <div id="leftnavcontainer">
      <div id="leftnavlogin">
      ...
      </div>
      <div id="leftnav">
      ...
      </div>
    </div>
    - this should be much easier to manage than using several floats.

    However, I'd personally recommend that you use either fixed or absolute positioning instead of floats, which are in many ways easier to control.

  5. Received thanks from:

    DannyM (30-11-2009)

  6. #5
    aka .:iGi:. Calcutter DannyM's Avatar
    Join Date
    Feb 2007
    Location
    Location Location!
    Posts
    915
    Thanks
    111
    Thanked
    125 times in 97 posts
    • DannyM's system
      • Motherboard:
      • Gigabyte Z68MA-D2H-B3
      • CPU:
      • Intel Core i5-2400
      • Memory:
      • 8GB Corsair Vengeance DDR3 - PC-12800
      • Storage:
      • 120GB A-Data SSD
      • Graphics card(s):
      • 1GB Nvidia ASUS 560Ti DirectuII
      • PSU:
      • Corsair 620W HX Modular PSU
      • Case:
      • Fractal Design Define Mini
      • Operating System:
      • Windows 7 Pro 64bit
      • Monitor(s):
      • 23" Dell UltraSharp U2311H
      • Internet:
      • 50Mb Virgin Media Cable Broadband

    Re: Help: How do I stack my div boxes?

    Quote Originally Posted by scaryjim View Post
    The positioning of floats is complex in HTML and not particularly consistently implemented either!! The best way of acheiving what you're after is not to have both the leftnav and login boxes floating, but to put them both in a containing div that is floating - so you'd have something like:
    Code:
    #leftnavcontainer { float: left; }
    in your CSS and
    Code:
    <div id="leftnavcontainer">
      <div id="leftnavlogin">
      ...
      </div>
      <div id="leftnav">
      ...
      </div>
    </div>
    - this should be much easier to manage than using several floats.

    However, I'd personally recommend that you use either fixed or absolute positioning instead of floats, which are in many ways easier to control.
    That makes so much sense, I feel like a right noob now, ha!

    I will try that, but I don't see how it wouldn't work, thank you very much!

  7. #6
    aka .:iGi:. Calcutter DannyM's Avatar
    Join Date
    Feb 2007
    Location
    Location Location!
    Posts
    915
    Thanks
    111
    Thanked
    125 times in 97 posts
    • DannyM's system
      • Motherboard:
      • Gigabyte Z68MA-D2H-B3
      • CPU:
      • Intel Core i5-2400
      • Memory:
      • 8GB Corsair Vengeance DDR3 - PC-12800
      • Storage:
      • 120GB A-Data SSD
      • Graphics card(s):
      • 1GB Nvidia ASUS 560Ti DirectuII
      • PSU:
      • Corsair 620W HX Modular PSU
      • Case:
      • Fractal Design Define Mini
      • Operating System:
      • Windows 7 Pro 64bit
      • Monitor(s):
      • 23" Dell UltraSharp U2311H
      • Internet:
      • 50Mb Virgin Media Cable Broadband

    Re: Help: How do I stack my div boxes?

    Did the trick jim!



    Thanks again

  8. #7
    Not a good person scaryjim's Avatar
    Join Date
    Jan 2009
    Location
    Gateshead
    Posts
    15,196
    Thanks
    1,231
    Thanked
    2,291 times in 1,874 posts
    • scaryjim's system
      • Motherboard:
      • Dell Inspiron
      • CPU:
      • Core i5 8250U
      • Memory:
      • 2x 4GB DDR4 2666
      • Storage:
      • 128GB M.2 SSD + 1TB HDD
      • Graphics card(s):
      • Radeon R5 230
      • PSU:
      • Battery/Dell brick
      • Case:
      • Dell Inspiron 5570
      • Operating System:
      • Windows 10
      • Monitor(s):
      • 15" 1080p laptop panel

    Re: Help: How do I stack my div boxes?

    No worries It's a good rule of thumb to have as few floats as possible on any given page, because they do interact with each other in an odd way

  9. #8
    jim
    jim is offline
    HEXUS.clueless jim's Avatar
    Join Date
    Sep 2008
    Location
    Location: Location:
    Posts
    11,457
    Thanks
    613
    Thanked
    1,645 times in 1,307 posts
    • jim's system
      • Motherboard:
      • Asus Maximus IV Gene-Z
      • CPU:
      • i5 2500K @ 4.5GHz
      • Memory:
      • 8GB Corsair Vengeance LP
      • Storage:
      • 1TB Sandisk SSD
      • Graphics card(s):
      • ASUS GTX 970
      • PSU:
      • Corsair AX650
      • Case:
      • Silverstone Fortress FT03
      • Operating System:
      • 8.1 Pro
      • Monitor(s):
      • Dell S2716DG
      • Internet:
      • 10 Mbps ADSL

    Re: Help: How do I stack my div boxes?

    Todays is?

    Tut tut.

  10. #9
    aka .:iGi:. Calcutter DannyM's Avatar
    Join Date
    Feb 2007
    Location
    Location Location!
    Posts
    915
    Thanks
    111
    Thanked
    125 times in 97 posts
    • DannyM's system
      • Motherboard:
      • Gigabyte Z68MA-D2H-B3
      • CPU:
      • Intel Core i5-2400
      • Memory:
      • 8GB Corsair Vengeance DDR3 - PC-12800
      • Storage:
      • 120GB A-Data SSD
      • Graphics card(s):
      • 1GB Nvidia ASUS 560Ti DirectuII
      • PSU:
      • Corsair 620W HX Modular PSU
      • Case:
      • Fractal Design Define Mini
      • Operating System:
      • Windows 7 Pro 64bit
      • Monitor(s):
      • 23" Dell UltraSharp U2311H
      • Internet:
      • 50Mb Virgin Media Cable Broadband

    Re: Help: How do I stack my div boxes?

    Quote Originally Posted by snootyjim View Post
    Todays is?

    Tut tut.
    Tut tut, you actually noticed

    I'm stripping that out soon. Going to put it in the login section, welcome joe blogs today is the xx/xx/xx and it's xx:xx

    Thanks for the spot though

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How many Sky+ Boxes?
    By aidso in forum General Discussion
    Replies: 6
    Last Post: 29-07-2008, 09:44 PM
  2. What to do with old stuff & boxes?
    By SiM in forum General Discussion
    Replies: 25
    Last Post: 11-06-2008, 08:28 PM
  3. Minimum DIV Height CSS
    By ACiD303 in forum Software
    Replies: 10
    Last Post: 24-04-2007, 02:31 AM
  4. Make a stack of things?
    By Trippledence in forum General Discussion
    Replies: 34
    Last Post: 14-09-2006, 12:15 AM

Posting Permissions

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