CSS - My Very Simple Ie5 Box Model Hack
Code:
div.somediv { width: 160px; padding: 20px; _width /**/: 200px; } no tantek hack, no holly hack, no external css imports, just a shame it doesnt validate! if you see the css filters page at my site (http://www.cyclomedia.co.uk) you'll see that the 200px rule is only read by ie5 and ie5.5. but i havent done extensive cross platform (mac) testing, but it works for me! Similar TutorialsI have been having my share of problems with CSS lately for this one site I'm working on (this is my 3rd thread here about it) and now after researching I believe this one is from what I think is called a box model bug. The problem is this: The border heights for my <div>'s are perfect in FF but when I test in IE the are too long! below is my code and a url to the project. Code: * { margin: 0; padding: 0; } body { background-color:#FFFFFF; text-align:center; font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#000000; } #site { width:775px; height:500px; margin:25px auto 0 auto; border:none; } #container { width:775px; height:500px; margin:0 auto 0 auto; border:1px solid #99CCCC; } #header, img { margin-top:10px; border:none; cursor: default; } #left { width:210px; height:201px; margin-top:80px; margin-left:20px; border-top:1px solid #99CCCC; border-right:1px solid #99CCCC; border-left:1px solid #99CCCC; float:left; } #menubar{ background-color:#FFFFFF; text-align:left; margin:0; padding:0; } #menubar li { display:block; font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#FF9933; list-style:none; text-decoration:none; border-bottom:1px solid #99CCCC; cursor:default; line-height:27.5px; } #menubar a { display:block; font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#FF9933; list-style:none; text-decoration:none; cursor:default; padding-left:5px; line-height:27.8px; } #menubar a.active { color:#99CCCC; } #menubar a:hover, #menubar a:focus, #menubar a:active{ color: #FFFFFF; background-color: #99CCCC; } #right { width:520px; height:390px; margin:15px 0 15px 0; border-top:1px solid #99CCCC; border-left:1px solid #99CCCC; float http://jjs5327.aisites.com/IMD311/index.html Does anyone have some suggestions that will make my sites <div>'s look the same in both IE and FF? Okay, so, like, now I'm attempting to fix what I've got in IE (except IE on a Mac, that's a lost cause, I think, and demographically not something I need to worry about for this group) and I read up on the box model hack here http://www.communitymx.com/content/...0989953B6F20B41 (it explains all the hacks but promotes the Tan hack). I tried a hack in at least one place in the code, where I could handle the code (mathematically speaking), and it didn't effect any noticeable changes. My problem is that my head explodes when I try to figure out what to do when I have mixed units of measurement. Like, a width of 60% with padding of ems or pixels or something. The article didn't say what to do there, and frankly I need a calculator for basic math, so...what do you do in those cases? In their examples, they used consistent units of measurement. In IE, the content below the header is not really working, not the way it should or does in FF. For one thing, the .announcement box gets shoved to the bottom of the page, underneath #newsbox. http://www.describe.org/homework/esdcar/ http://www.describe.org/homework/esdcar/esdcar.css Also, why do the lines I used (dividing entries in #newsbox, for instance) change from skinny little lines to big fat wedges in IE? (And can I make it not do that?) surely someone has found this befo Code: <style> .w1 { background-color: red; color: white; width: 200px; } .w2 { background-color: blue; color: white; padding: 10px; width: 180px; width: "200px"; } </style> <div class="w1">no padding</div> <div class="w2">10px padding</div> IE5.01,IE5.5 (and IE6 in quirks mode) read the width parameter in the quotes, all other browsers ignore it. (FF 1.5RC1, OP8.5, NS7, IE6 (strict), IE5.2 mac, Safari) of course, this is invalid CSS and wont validate, but i used to use a nasty comment escape sequence to do it (yeah i know about conditional comments). when reading an identifier in CSS IE will treat two dots in a class decleration as one: accepted rules (strict mode): Code: win ie 5.01: p..class, p./**/.class win ie 5.5 : p..class win ie 6 : p..class, p./**/.class, p./**/class, p/**/.class win ff 1.5 : p./**/class, p/**/.class (comments ignored) win opera : (as firefox) win ns 7.0 : none! nevermind got it sorted out Quote: hi, i just made a footer the other day and had to realize (at work today) that it is not quite there in IE where it is in FF. it seems to have to do with another element on the page (the navigation) - you will see what i mean by viewing the following page in IE: http://www.chocolateriewanders.com could you just tell me which one of the endless hacks for IE i need to apply - or how you call this alignment problem (then i can look it up in google myself ... i just need to know how you call this) thanks Hi all, I need some help. I know I need an IE hack to make my drop down menu on the header of this page work correctly (hover over 'pictures', 'rides', or 'maps') but for the life of me I can't seem to find what that workaround (hack) is. Please help! Oh yeah, of course, it work perfectly fine in Firefox. Here's a copy of the 2 CSS files I am using for this page... main2.css header.css And yeah, I am still working on the header, that's why it looks kinda empty right now. =) Manny Hello all, I'm really interested in hearing the opinions of those more seasoned in web development. I have been working hard at learning CSS and believe I have really improved my web design skills because of it. I love working with CSS and have completely freed myself from tables. But... I am so tired of playing for hours with the coding just so my page looks okay in both IE and FF. I'd much rather my page look great in FF (my prefered browser) and to heck with IE. I have made my stand and will no longer design my personal pages for IE. I have a clear message on one of them telling my visitors to wise up and download FF. Of course my audience allows me to get away with this. I realise that if your visitors are average surfers who barely know how to do a search on google, they aren't about to deviate from IE. But for those audiences who have a little more internet experience, do you think it's cool to try and push them into using FF? In terms of usage it's clearly on the rise, IE has been steadily declining. I'd really like to see IE hit bottom. The way I see it, as long us the development community continues to jump through hoops so people can keep using IE or other inferior browsers, there will be little motivation to develop some solid web browser standards. Any thoughts? Yeah, we all know IE sucks because we have to do all types of extra css to make it work. I just did a design update on my site. I did my usual, worked the design with Chrome and Firefox. I got it all working with those browsers, and them I just opened IE 7 so see how much more work I need to do for IE. Well to my surprise, everything was correct. I checked IE 8. Same thing. It all looked correct. Now, I may have had a stroke and didn't know. So I'm asking if someone can look at my site with there IE 7 or 8 and confirm that looks alright. www. netgamegurus .com I just don't believe that I could have coded it that perfect. From my experience it just not possible. Sorry about the URL hack, but I came to this forum for css support and it's kinda hard to get css suport if we can't post URL's to show our css at work. As I understand it, IE supports "hover" only when applied to a link, where with Firefox and Safari you can apply hover to any element. I am wondering if any of you know of a hack for IE to make hover applicable to any element. Below is my CSS. Code: .amy-navigation { padding: 30px 15px 0px 15px; height: 22px; float: right; } div.amy-navigation:hover { background-color: white; text-decoration: none; border-bottom: solid 1px #b1cc8d; } div.amy-navigation:hover > a { color: #acadac; text-decoration: none; } Using Firefox or Safari you can see what I'm trying to do in my header at www.amydelez.com Hello, Is there a hack for Safari 3. I found this hack : @media screen and (-webkit-min-device-pixel-ratio:0) { #safari { display: block; } } The problem with this hack is that he is valid for all verison of Safari. My need is a hack only for Safari 3. Thank you in advance for your help. I read about a cross browser min-width hack he http://www.hackszine.com/blog/archi..._css_minhe.html Which seemed simple enough, but when I try it doen't seem to work. Here's my code Code: <a href="#" class="nav"><img src="/images/left.gif" alt="" />Next<img src="right.gif" alt="" /></a> Code: .nav { display:block; min-width:100px; width: auto !important; width: 100px; background-image: url(/images/btn_section_nav_bg.gif); } My end goal is to have a button that can expand to whatever width the text is inside it. Anyway TIA So, I have an app that allows the user to select images from a list of thumbnails. The thumbnails have an 'on' and 'off' state, but also have a drop shadow. I can get the drop shadow to render nicely in IE6 using a PNG hack, but I can't seem to find a hack that will allow me to use a PNG sprite so I can have the on and off state in the same image. Any suggestions would be great. When the :not pseudoclass is used with an element selector in Firefox, it works as expected, excluding the selector inside the parentheses. But used by itself or attached to the * selector, it applies the rule to ALL elements. This unexpected behavior can be exploited to write Mozilla-specific patches to your CSS code. example:
html4strict Code: Original - html4strict Code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>Testing :not Hack</title> <style type="text/css"> :not([id]) p { font-weight: bold; } </style> </head> <body id="thisthing"> <p>This is a test.</p> <p id="test">This is a test.</p> <div>This is a test.</div> </body> </html> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> The idea is to set the ID of the parent and browsers which correctly interpret this selector will not apply the rule to anything; also those browsers which don't already support it will simply ignore it. The :not selector is part of the new CSS3 recommendation. Here's just the css code for the hack: css Code: Original - css Code :not([id]) example { /* Moz/FF/Netscape code here */ } :not([id]) example { Hey guys nice forums.....am a css noobie i wanna know one thing how do i make a div stretch horizontally 100% , basically i want my website to be divided into 2 colors black and white the lower part would be black and the upper part would be white , now am not using a div container as i read through previous topics before so am using 2 divs as follows <div id="White">White area</div> <div id="Black">Black area</div> when i preview in IE i see the colors as i want but the divs do not stretch 100% as i said in the css. how do i do it ? hope i made myself clear on this I've encountered the italics problem with IE and am trying to work around it. I followed the hack from the http://www.positioniseverything.net...alicbug-ie.html page but it really screws things up. My page is cut, more or less, into 3 sections: header, main, footer. Since I don't use any italics in either the header or footer, the rule needs only to apply to main. It CAN apply to the others, but it doesn't need to. Now, when I apply the hack, instead of my page lining up with the 'header' on the left hand side and the main on the right hand side, it completely pushes my 'main' area down so that it doesn't start until after the header and I have no idea why? I noticed that if I put the hack in each particular page (rather than in the external file sheet) then it works, but why? If you are having problems with Son of Suckerfish and IE7, where the drop down menu will not disappear like it should. Take out the javascript because you do not need it with IE7, but if you still want IE6 to work then put it in. For IE7, you need to add Code: *:first-child+html #nav { height: 1%; } *:first-child+html #nav li { height: 1%; } to your css and you will be fine. Don't ask me why, Don't ask how, i just chalk it up to just IE Here's how it works: first you make CSS rules like these, for example:
css Code: Original - css Code body { font-size: small; } body.0 { font-size: x-small; } #content { width: auto; } .0 #content { width: 100%; } body { and then you specify the class and id attributes: html4strict Code: Original - html4strict Code <body class="0"> <div id="content"> <body class="0"> The first of each rule targets strict standards mode, while the second of each rule targets quirks mode, including accidentental quirks mode due to a failure to read and parse the DTD. Why does it work? Because in standards mode, numeric classes (0, 1, 2, 23, 586, etc.) are correctly not applied to the rendered document, whereas with Quirks Mode in IE and Opera, these styles are parsed and applied. Technically the dot-zero rules will not validate, but the HTML will. So don't freak out if your CSS is flagged as invalid; this hack wasn't intended for standards mode anyway. Note: This hack will not work on Firefox, but since its default mode is not quirky, it doesn't matter. I'm trying to apply the min-height hack for IE shown here http://www.greywyvern.com/code/min-height-hack.html It entails floating a 1 pixel wide box, then put your content below, then clear the float. It seems to work fine, but something in my layout is screwing this up royally on IE. Can someone take a look at this on IE and compare it to firefox. What in the world is IE doing here? http://section31.us/temp/rateyourmo...min-height.html That layout is just part of a larger website that i'm working on for fun. http://section31.us/temp/rateyourmovie.com/index1.php I am creating a variation on the son of suckerfish drop down menu - I would post a link to that code but the forum wont allow me so please use google :-( Anyway the basic idea is to display a drop down with a series of links which are floated from left to right. I have tweaked the code and it works nicely in IE 8, FF 3 (os x and xp) and safari3 but I have a minor problem in IE 7 (I haven't dared look at IE 6 yet!) Basically the drop down is appearing too far off to the right in IE 7. I can fix it by using a conditional margin-left: -4.5em but this seems like a hack and i don't know how well it will work across different resolutions. If someone could give me some pointers on this I would appreciate it :-) You can see the code in action at www esuri-apartment.com/css_menu/index.html (apologies for the formatting but i'm blocked from posting urls which is a serious pain!) Many thanks! Toby Here is the code Code: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta name="generator" content="HTML Tidy, see www.w3.org"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="stylesheet" type="text/css" href="menu.css" /> <script type="text/javascript" src="menu.js"></script> <title> Insert title here </title> </head> <body> <ul id="nav"> <li><a href="#">Menswear</a> <ul> <li><a href="#">Shirts</a></li> <li><a href="#">Jackets</a></li> <li><a href="#">Trousers</a></li> <li><a href="#">Accesories</a></li> <li><a href="#">Suits</a></li> <li><a href="#">Shirts</a></li> <li><a href="#">Jackets</a></li> <li><a href="#">Trousers</a></li> <li><a href="#">Accesories</a></li> <li><a href="#">Suits</a></li> <li><a href="#">Shirts</a></li> <li><a href="#">Jackets</a></li> <li><a href="#">Trousers</a></li> <li><a href="#">Accesories</a></li> <li><a href="#">Suits</a></li> </ul> </li> </ul> </body> </html> menu.css: Code: #nav, #nav ul { padding: 0 20px; margin: 0 0 1em; list-style: none; width:36em; float:left; font-size:1.1em; } #nav li { float: left; background-color:red; text-align:center; padding:0; width:10em; } #nav li a { display:block; padding:0.25em 2em; text-decoration:none; width:6em; } #nav li ul { position: absolute; width: 40em; height:10em; left: -999em; /* This appears to fix the problem in IE 7 but i dont like it * margin-left: -4.53em; */ border:1px solid black; padding-bottom:2em; } #nav li li { background-color:white; width: auto; } #nav li li a { padding: 0.5em 0.5em; } #nav li:hover ul { left: auto; } #nav li:hover ul, #nav li.sfhover ul { left: auto; } #nav ul ul { border: none; float:left; } #nav li ul li ul { height:1em; width: 6em; } menu.js (hack for ie): Code: sfHover = function() { var sfEls = document.getElementById("nav").getElementsByTagName("LI"); for (var i=0; i<sfEls.length; i++) { sfEls[i].onmouseover=function() { this.className+=" sfhover"; } sfEls[i].onmouseout=function() { this.className=this.className.replace(new RegExp(" sfhover\\b"), ""); } } } if (window.attachEvent) window.attachEvent("onload", sfHover); Situation Hi everyone. I'm trying to make an <img> hangover the right side of a <div> so half is inside and half outside. I'm applying a float with negative margins. Problem The problem is ie6 keeps cutting off the half that's suppose to be outside. Solution? Does anyone know how I can accomplish my situation in ie6? Also, I'm interested in learning the IE6 CSS Model. Can anyone point me to where I can learn exactly how it works? Thank you. |