How to get a div less than 20px height IE6

This is a discussion on "How to get a div less than 20px height IE6" within the Web Page Design section. This forum, and the thread "How to get a div less than 20px height IE6 are both part of the Design Your Website category.



Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jul 3rd, 2007, 12:13
Up'n'Coming Member
Join Date: Jul 2005
Location: uk
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
How to get a div less than 20px height IE6

Hi I have just noticed that IE6 has a weird default that does not allow you to have a div with a height less than 20px even if you specify it to be 1px. In FF the code is displayed correctly. I tried setting the margins to 0 but this did not work. As there is no content in the div I am a little puzzled. Any help Yes please

css:
Code: Select all
#container {
 height: 30px;
}
#top {
 background-color: #0099FF;
 height: 1px;
}
#bottom {
 background-color: #999999;
 height: 29px;
}
html:
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link href="css/global.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="container">
  <div id="top"></div>
  <div id="bottom"></div>
</div>
</body>
</html>
Reply With Quote

  #2 (permalink)  
Old Jul 3rd, 2007, 12:21
SuperMember

SuperMember
Join Date: May 2006
Location: North West, UK
Age: 21
Posts: 1,173
Thanks: 0
Thanked 0 Times in 0 Posts
Re: How to get a div less than 20px height IE6

Did you try to reset the padding as well?

Code: Select all
* {margin:0; padding: 0;}
That will set all margins and paddings to 0 which may work.

May I ask why you are using a 1px high div. It looks like you are doing it to get a 1px thick line. Why not just use a

Code: Select all
border-top: 1px solid #0099FF;
This will give you a solid 1px line at the top of whatever element you apply it to.

Have you got a screen dump of, or link to, the site or a mock-up? What exactly are you trying to achieve here?

Pete.
Reply With Quote
  #3 (permalink)  
Old Jul 3rd, 2007, 12:44
Reputable Member
Join Date: Jun 2007
Location: Bellevue, SK, Canada
Age: 28
Posts: 222
Thanks: 0
Thanked 0 Times in 0 Posts
Re: How to get a div less than 20px height IE6

Try this in the <head> of your html:

Code: Select all
<!--[if IE]>
<style type="text/css"> 

#top {
 height: -20px;    }

</style>
<![endif]-->
It's called a conditional.. I hope I understood the problem correct and this solves the problem..
Reply With Quote
  #4 (permalink)  
Old Jul 3rd, 2007, 13:38
Up'n'Coming Member
Join Date: Jul 2005
Location: uk
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
Re: How to get a div less than 20px height IE6

Quote:
Originally Posted by delusion View Post
Try this in the <head> of your html:

Code: Select all
<!--[if IE]>
<style type="text/css"> 
 
#top {
 height: -20px;    }
 
</style>
<![endif]-->
It's called a conditional.. I hope I understood the problem correct and this solves the problem..
Thanks delusion yes you understood the problem but it did not work. I found a work around but I am curious about why it happens so if anyone knows??
Reply With Quote
  #5 (permalink)  
Old Jul 3rd, 2007, 13:40
SuperMember

SuperMember
Join Date: May 2006
Location: North West, UK
Age: 21
Posts: 1,173
Thanks: 0
Thanked 0 Times in 0 Posts
Re: How to get a div less than 20px height IE6

Could you psot your solution incase anyone else has the same problem?

Sorry I haven't a clue why this happens.

Pete.
Reply With Quote
  #6 (permalink)  
Old Jul 3rd, 2007, 13:49
Up'n'Coming Member
Join Date: Jul 2005
Location: uk
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
Re: How to get a div less than 20px height IE6

Quote:
Originally Posted by pa007 View Post
Did you try to reset the padding as well?

Code: Select all
* {margin:0; padding: 0;}
That will set all margins and paddings to 0 which may work.

May I ask why you are using a 1px high div. It looks like you are doing it to get a 1px thick line. Why not just use a

Code: Select all
border-top: 1px solid #0099FF;
This will give you a solid 1px line at the top of whatever element you apply it to.

Have you got a screen dump of, or link to, the site or a mock-up? What exactly are you trying to achieve here?

Pete.
Ta paa007
Its not a margin or pading problem. Yes you are right about the line thing. What I wanted was a dashed line which I made like this:
Code: Select all
#top {
 border-top-width: 1px;
 border-top-style: dashed;
 border-top-color: #CCCCCC;
}
but I noticed when you specify the height of the div it gives you 20px in IE6. If you take off the height it does seem to work!! The other way is to but the dash as a background image which is what I normanly do.
Reply With Quote
  #7 (permalink)  
Old Jul 3rd, 2007, 13:56
Up'n'Coming Member
Join Date: Jul 2005
Location: uk
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
Re: How to get a div less than 20px height IE6

Quote:
Originally Posted by pa007 View Post
Could you psot your solution incase anyone else has the same problem?

Sorry I haven't a clue why this happens.

Pete.
One way is not to specify the height:
Code: Select all
#top {
 border-top-width: 1px;
 border-top-style: dashed;
 border-top-color: #CCCCCC;
}
The other is to use a background image but it does not really solve the general problem it only fixs what I need to achieve.
Code: Select all
#top {
 height: 20px;
 padding-top: 7px;
 text-align: center;
 margin-top: 35px;
 background-image: url(../shared-images/dashed_line.gif);
 background-repeat: repeat-x;
}
Any thoughts, yes please
Reply With Quote
  #8 (permalink)  
Old Jul 3rd, 2007, 14:25
SuperMember

SuperMember
Join Date: May 2006
Location: North West, UK
Age: 21
Posts: 1,173
Thanks: 0
Thanked 0 Times in 0 Posts
Re: How to get a div less than 20px height IE6

It's odd, it must be one of IE's quirks and lets face there are a few. IE7 is ok but you're often fighting a losing battle with IE6.

Glad you found a solution, I'll bear it in mind in future.

By the way, you should get into the habit of writing your css shorthand. So you have:

Code: Select all
#top {
 border-top-width: 1px;
 border-top-style: dashed;
 border-top-color: #CCCCCC;
}
This could be:

Code: Select all
border-top: 1px dashed #ccc;
Pete.
Reply With Quote
Reply

Tags
20px height, div, ie6

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
100% height RZX Developer Web Page Design 11 Mar 29th, 2008 10:23
CSS Div height problem dryjoy Web Page Design 1 Jan 6th, 2008 18:05
How to make a table height equal to the browser height ? subhadip Starting Out 4 Sep 20th, 2007 07:56
100% div height jimz JavaScript Forum 2 Mar 22nd, 2006 00:53


All times are GMT. The time now is 13:17.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43