Results 1 to 5 of 5

Thread: CSS - Divs I'm lost

  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

    CSS - Divs I'm lost

    It's been a pretty long day and I'm lost, it's been a while since I've done much web design work and I've mainly been doing PHP today but can anyone shed some light please?

    http://dmajor.me.uk/test/testing-ground.html

    I've got this HTML file:

    Code:
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <link href="style.css" rel="stylesheet" type="text/css" />
    </head>
    
    <body>
    <div id="mainprodbox">
    	<div class="mainprodboximg">
        	<div class="mainprodboxtitle">
            	<div class="mainprodboxbutton">
                </div>
    		</div>
    	</div>
    </div> 
    <div id="mainprodbox">
    	<div class="mainprodboximg">top
        	<div class="mainprodboxtitle">middle
            	<div class="mainprodboxbutton">bottom
                </div>
    		</div>
    	</div>
    </div>            
    </body>
    </html>
    And this stylesheet:
    Code:
    @charset "utf-8";
    /* CSS Document */
    
    #mainprodbox {float: left; width: 250px; height: 300px; border: 1px solid #000;}
    .mainprodboximg {min-height: 100px; background-color: #F00;}
    .mainprodboxtitle {width: 100%; min-height: 150px; text-align: center; background-color: #09f;}
    .mainprodboxbutton {width: 100%; min-height: 50px; text-align: center; background-color: #999;}
    The divs with that code are overlaying each other, I don't want them to do that, I want them to stack on top of each other with the set heights.

    I want it to look like this:



    Any ideas? I know I've probably missed something so simple.

  2. #2
    HEXUS webmaster Steve's Avatar
    Join Date
    Nov 2003
    Posts
    14,283
    Thanks
    293
    Thanked
    841 times in 476 posts

    Re: CSS - Divs I'm lost

    You have two elements with the same ID - this is illegal and probably one of the first things to address.

    Also you have no CSS reset. That's going to lead to some inconsistencies in certain browsers.

    Due to consumption of port I cannot give sound advice, only point out errors. Hopefully somebody else will now jump to the rescue.
    PHP Code:
    $s = new signature();
    $s->sarcasm()->intellect()->font('Courier New')->display(); 

  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: CSS - Divs I'm lost

    Quote Originally Posted by Steve View Post
    You have two elements with the same ID - this is illegal and probably one of the first things to address.

    Also you have no CSS reset. That's going to lead to some inconsistencies in certain browsers.

    Due to consumption of port I cannot give sound advice, only point out errors. Hopefully somebody else will now jump to the rescue.
    I didn't realise the id issue but the problem still occurred when I used it as a class.

    The only css resets I have ever used are margin and padding but I'm open to ideas/suggestions thanks

  4. #4
    Boooooom Barakka's Avatar
    Join Date
    Jul 2003
    Location
    ...fixing it in post
    Posts
    1,361
    Thanks
    61
    Thanked
    127 times in 104 posts

    Re: CSS - Divs I'm lost

    It's because you've nested the <div>'s within each other, for what you've drawn you want
    Code:
    <div id="mainprodbox">
        <div class="mainprodboximg"></div>
        <div class="mainprodboxtitle"></div>
        <div class="mainprodboxbutton"></div>
    </div>
    Quote Originally Posted by The Mock Turtle
    “Reeling and Writhing, of course, to begin with, and then the different branches of arithmetic -- Ambition, Distraction, Uglification, and Derision."
    System:Atari 2600 CPU:8-bit 6507 (1.19MHz) RAM:128 bytes Colours: 16 (4 on screen) Resolution: 192x160

  5. Received thanks from:

    DannyM (17-03-2012)

  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: CSS - Divs I'm lost

    Quote Originally Posted by Barakka View Post
    It's because you've nested the <div>'s within each other, for what you've drawn you want
    Code:
    <div id="mainprodbox">
        <div class="mainprodboximg"></div>
        <div class="mainprodboxtitle"></div>
        <div class="mainprodboxbutton"></div>
    </div>
    I feel like a complete idiot now, the phrase "sleep on it" has never been so true for me.

    Thank you very much!

Thread Information

Users Browsing this Thread

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

Posting Permissions

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