How to set div width when there is no content inside it

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • padmas
    New Member
    • May 2010
    • 3

    How to set div width when there is no content inside it

    In firefox and ie8 the middle div is ignoring the width when there is not content.
    Please help me fix it to work the same way for ie7 also

    I cannot remove the width for the main 3 div's
    Code:
    **************************************************************************
    <head>
        <title>Untitled Page</title>
    <link href="ie7.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <div class="divfloatLeft" id="maincontentrow1">
         <div class="healthrisk">
              &nbsp;healthrisk
         </div>
         <div class="healthylifestyles">
    	
         </div>
         <div class="regioncontent">
         regioncontent goes here
                 </div>
    	     </div>
    
    </body>
    </html>
    
    **************************************************************************
    here is the CSS for the above htm
    Code:
    .healthrisk
    {
        width:27%;
        padding-right:20px;
        float:left;
    }
    .healthylifestyles
    {
    	width:40%;
    	padding-right:20px;
    	float:left;
    	position:inherit;
    }
    .regioncontent
    {
        width:27%;
        float:left;
    }
    .divfloatLeft
    {
        float:left;
        display:inline;
    }
    #maincontentrow1
    {
        width:100%;
    }
    I can put div inside the main div's like below:
    Code:
    <div class="healthylifestyles">
    	<div style="margin-top:0px;"></div>
         </div>
    Attached Files
  • drhowarddrfine
    Recognized Expert Expert
    • Sep 2006
    • 7434

    #2
    When you are setting the percentage, ask percentage of what? It's always the parent. So what is the parent set to?

    Comment

    • padmas
      New Member
      • May 2010
      • 3

      #3
      #maincontentrow 1
      {
      width:100%;
      }

      parent is set to 100%

      Comment

      • drhowarddrfine
        Recognized Expert Expert
        • Sep 2006
        • 7434

        #4
        And that is 100% of what?

        Comment

        • padmas
          New Member
          • May 2010
          • 3

          #5
          you asked what is parent set to ........ the parent Div is set to 100% width...

          Its 100% of the browser

          Comment

          • drhowarddrfine
            Recognized Expert Expert
            • Sep 2006
            • 7434

            #6
            100% of the browser? Where do you set the "browser" width?

            Comment

            Working...