Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Overclock.net Forum > FAQs

 
 
LinkBack Thread Tools
Old 09-08-06   #1 (permalink)
Programmer
 
sniperscope's Avatar
 
amd nvidia

Join Date: Apr 2006
Location: Kent (England)
Posts: 1,250

Rep: 90 sniperscope is acknowledged by some
Unique Rep: 77
FAQs Submitted: 3
Trader Rating: 0
Default How to: Get around Internet explorer's rendering bugs

Theres a handy little trick I use to get around irritating IE issues.

Use:

Code:
html>body *tag you want to use, e.g. div.leftbar* {}
so, for example it would be like:

Code:
html>body div.leftbar {  padding: 0;
                         margin: 0 auto;
                         text-align: left;
}
This code is handy because IE cannot see or execute the CSS code that is declared after html>body, but any other modern browser, E.G. Firefox, Opera and Safari can see and execute the code. Therefore, you put the code that you want IE to execute in normal CSS layout, but code that you only want modern browsers to execute after the html>body declaration (because IE would mess it up otherwise). Heres a common example:

IE likes to add a 3px margin to images sometimes. To get around this problem, we can use this trick. Heres how:

Code:
/* Give the image a class. For this example, we'll use img.ocnlogo. */

img.ocnlogo { margin: -3px: /* <--- This is the code to get rid of the 3px margin around the image in IE. IE will execute this accordingly. */
}

html>body img.ocnlogo{
                         margin: 0;
}
Basically all we are doing is declaring what we want IE to do in the normal CSS code. However, since other browsers do not add the 3px margin like IE does, if they will be allowed to execute this they will render the image with a margin of -3px. To prevent them from doing this, we use the html>body trick to overwrite what we said to the browser previously, leaving only IE executing the code and rendering it desirably. So basically all we are doing is writing separate CSS code for the browsers, where IE is executing the normal code, other browsers executing the code within html>body. However, you should only use this if you cannot solve the problem universally using the regular cross-compatible css code that IE amongst all other browsers can see, as this method involves more typing up so it may take longer to do and increase the size of your CSS file slightly, however it is more than worth it, trust!

Understand!? Please comment if you need further explanation.

The reason why this works is that IE is meant to recognise html>body but it can't because its a bug in IE. However it is extremely easy and useful to implement. I have solved many problems using this which would otherwise be deemed near impossible to solve. It takes intelligence and coding skill to implement this effectively, as you need to have a good knowledge of the CSS code to correct IE's problems effectively.

Revision history:
  • 13th September 2006 - Edited the text to correct a couple of mistakes and improve clarity of explanations
__________________
System: Bob
CPU
AMD Athlon 64 3800+
Motherboard
ASUS A8N- SLI Premium
Memory
2GB (2X1GB) Corsair XMS Pro LED TwinX DDR400
Graphics Card
XFX GeForce 7800GT Extreme Edition
Hard Drive
2x200GB Barracuda SATA RAID0 + 250Gb ATA
Sound Card
AC'97
Power Supply
Antec TruePower 550W
Case
Thermaltake Armour
CPU cooling
Stock
GPU cooling
Stock
OS
Windows Vista Home Premium x64
Monitor
Hanns G 19" widescreen HW191D

Last edited by sniperscope : 01-06-07 at 11:56 AM
sniperscope is offline sniperscope's Gallery  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools



All times are GMT -5. The time now is 06:24 PM.


Overclock.net is a Carbon Neutral Site Creative Commons License

Terms of Service / Forum Rules | Privacy Policy | DMCA Info | Advertising | Become an Official Vendor
Copyright © 2009 Shogun Interactive Development. Most rights reserved.
Page generated in 0.08695 seconds with 8 queries