Jump to content

increasing height


csckid

Recommended Posts

<div id="container" style="background-color:#CCC; height:10px">
<div id="middle" >
              hello
		<div id="middleleft">
            
                               egg
                                <br><br><br><br><br>
		</div>
                       bye          
</div>

</div>

 

The above code works different in internet explorer and mozilla.

 

if I remove this "height:10px" both explorer outputs the same result.

What I wanted is, output should be similar to internet explorer; but I need to specify minimum height of the div "#container".

 

how do I achieve this?

 

Thanks

 

 

Link to comment
Share on other sites

I see what you mean. I've tested this and it the CSS renders the same in Chrome, FF and IE6:

 

<div id="container" style="background-color:#CCC; min-height:10px;">
<div id="middle" >
              hello
		<div id="middleleft">
            
                               egg
                                <br><br><br><br><br>
		</div>

                       bye          
</div>

 

Notice that all I done was specified an minimum height. Once the content of your div goes beyond 10px the grey background will automatically 'stretch'. If anything IE6 was behaving problematically rather than any other browser type. Nine times out of ten it'll be IE6.

 

Link to comment
Share on other sites

This except should solve your issue:

 

* html

 

Internet Explorer 6 only will parse a CSS rule that starts with * html. This doesn’t really make any sense and so other browsers ignore the rule, so this can be used to serve specific CSS to Internet Explorer 6 only. Internet Explorer correctly interprets this and so also ignore the CSS. As a simple example, IE6 treats the property height as if it were min-height, so we might do:

 

.box { min-height: 50px; }
* html .box { height: 50px; }

 

All modern browsers will interpret the first rule, and give the box a minimum height of 50 pixels. IE6 will then also parse the second rule which will overwrite the first and so it will give the box a height (which it treats like min-height) of 50 pixels.

 

Hacks or filters do have a bit of a bad press these days, mainly because with modern browsers you really shouldn’t need to use them. However I think this is a legitimate way to target IE6 especially if you only have a few things to fix. I would suggest however that you put your fixes into a separate stylesheet rather than leaving them inline. Just make sure that stylesheet comes after the main stylesheet in the source so the rules overwrite the existing ones.

 

Source: http://www.edgeofmyseat.com/blog/developing-css-for-ie6-and-7

Link to comment
Share on other sites

Hacks are not very good, as they are hacks, and there is no knowing what will happen with other browsers in the future - maybe some browser will start spontaneously reading the supposed IE6 only code. On top of this, other browsers have to parse the code, even if they don't read it, which is inefficient.

 

For these reasons, using conditional comments to target IE6 is the preferred method of targeting that browser specifically.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.