in a CSS file, is there a way to give a specific height for a DIV that only applies on IE ONLY, and at the same time, give that same DIV another height that applies to all browsers except for IE ? thank you so much in advance ...
views:
46answers:
4
A:
Create 2 css files, one for IE and one for the other browsers
Load the css file according to the browser like described here
Pere Villega
2010-07-28 11:45:39
thank you for your reply, but I don't want to create another CSS file, I need the height property inside the same CSS file, I tried both hacks here, but non of them worked, because I use IE8 !! I need a way (or hack) to separate some IE CSS properties (like height) inside ONE SINGLE CSS file but not seprate files, as I exactly asked above
unprecedented
2010-07-28 13:51:49
+2
A:
You can create an IE-specific stylesheet and use IE Conditional statements.
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="iespecific.css" />
<![endif]-->
This way, you basically have two stylesheets; one for IE and other for rest of the standard-compliant browsers.
Hacks could have been used such as:
_height:500px;
*height:500px;
But that is not recommended.
See Also:
Sarfraz
2010-07-28 11:45:53
thank you for your reply, but I don't want to create another CSS file, I need the height property inside the same CSS file, I tried both hacks here, but non of them worked, because I use IE8 !! the tutorial you refered to was great, but it's all about importing specific CSS files not separating some CSS properties from specific browsers inside ONE SINGLE CSS file, as I exactly asked above
unprecedented
2010-07-28 13:47:36
@unprecedented: Why you don't want to use two? Did you know it is good practice and better than using hacks. Also this is the way suggested by experienced folks out there.
Sarfraz
2010-07-28 13:52:53
I do not need to create a whole css file just for a single height property, it's a big system and we do not want to increase the number of files created.
unprecedented
2010-07-28 15:42:08
A:
try this
<style>
#mydiv { height:800px; }
</style>
<!--[if IE]>
<style>
#mydiv { height:500px; }
</style>
<![endif]-->
Starx
2010-07-28 11:47:31
This is not possible. Check this http://jsfiddle.net/z4Smy/ tested on ie6, ie8, ff3, safari, opera works
Starx
2010-07-28 15:53:39
oops i thought I should put this code inside the css file itself, forgive me ...
unprecedented
2010-07-28 16:28:05
thank you for your help, I used this method to solve the problem from inside the html file (not from the css file)
unprecedented
2010-07-28 16:28:40
+1
A:
I have used the following and it worked in IE8. Put the following code within tag.
You can watch the online version from here, http://nazmulweb.com/site5/demo/iecss/
<style type="text/css">
#tgtDiv
{
height: 300px;
width: 400px;
border: 1px solid green;
}
</style>
<!--[if IE]>
<style type="text/css">
#tgtDiv
{
height: 300px;
width: 400px;
border: 5px solid red;
}
</style>
<![endif]-->
Hoque
2010-07-28 14:24:51