CSS Help Needed

Discussion in 'CSS' started by zahidprimex, Aug 13, 2009.

  1. #1
    I used these code below to define two settings in css

    #main{
    	height:auto;
    	width: 100%;
    	border-color: black;
    	border: 2px;
    	border-style: solid;
    #mainleft{
            height:auto;
    	width: 190px;
    	float:left;
    	border: 1px;
    	border-style: solid;
    	border-color: black;
    }
    Code (markup):
    Then I used these code in html page which produce 2 boxes.

    
    <div id="main">
    <div id="mainleft">
    KKKK
    <br>
    <br>
    <br>
    <br>
    <br>
    KKKKK
    </div>
    Zahid
    <br>
    <br>
    <br>
    <br>
    Zahid
    </div>
    
    Code (markup):
    Now I want to put the box mainleft in main so the height of main changes with the height of mainleft.How can I do it?
     
    zahidprimex, Aug 13, 2009 IP
  2. AssistantX

    AssistantX Peon

    Messages:
    173
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #2
    
    #main{
    	height:auto;
    	width: 100%;
    	border-color: black;
    	border: 2px;
    	border-style: solid;
    #mainleft{
            height:auto;
    	width: 190px;
    	float:left;
    	border: 1px;
    	border-style: solid;
    	border-color: black;
    }
    HTML:
    The above syntax is wrong as you did not close #main (No closing } )

    To extend #main div, add overflow: auto; property to #main
     
    AssistantX, Aug 13, 2009 IP
  3. myst_dg

    myst_dg Active Member

    Messages:
    224
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    58
    #3
    Here's an article about various ways of auto-height nested divs:
    http://gtwebdev.com/workshop/floats/enclosing-floats.php
    Code (markup):
    Btw, I got to know this from Stomme poes. :)
     
    myst_dg, Aug 13, 2009 IP