Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
Conditional Comments?
Old 10-17-2008, 11:03 AM Conditional Comments?
rolda hayes's Avatar
Wannabe Adventurer...

Posts: 960
Name: Darren
Location: England
Trades: 0
Hi Please have a look here.

I'm playing around with a css menu and have noticed that in all browsers (except IE7) the menu bar dosn't line up with the background image.

Would it be better to resize the image for the other browsers and then use a conditional comment for IE7?

I'm not sure how to go about doing this in the style sheet though?

Cheers,
__________________
I Just a test to see what happens...
Please login or register to view this content. Registration is FREE

"Let us be thankful for the fools. But for them the rest of us could not succeed..."
rolda hayes is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-17-2008, 12:07 PM Re: Conditional Comments?
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
This goes against the philosophy of a lot of the people here, but you can send a message to IE7 inside of a stylesheet by prefacing a statement with a star(*), like this:
Code:
height: 100px; /*a normal statement that affects all browsers*/
*height: 110px; /*a statement that overrides, for IE7 and below*/
This is considered a hack, because it takes advantage of a bug in IE7 that allows the *statement to be parsed, even though it begins with a strange character, which, if IE7 correctly identified this, would cause it to be ignored.

IE8 will likely correct this bug, since it is extremely famous, and even being used by Yahoo to target IE7 and below.
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 10-17-2008, 08:07 PM Re: Conditional Comments?
vangogh's Avatar
Post Impressionist

Posts: 10,688
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
Abel you realize we now have to throw you out of the club. I think using the hack invalidates your membership card. I'll have to check the documentation.

Darren I'd do it exactly how you suggested. I find conditional comments to be the best solution to IEs quirks. I've seen some think conditional comments are really just another hack, but to me they're the best solution until I see something better.

The way I usually set up conditional comments is:

<!--[if IE]>
<link rel="stylesheet" href="ie-style.css" type="text/css" />
<![endif]-->

and then place any IE specific styles in the ie-styles.css (or whatever you want to name it). You want to place the conditional comment after the code that links to your general styles or IE will end up using the general styles.

You can also target specific versions of IE if you want too.

<!--[if IE 6]>
<!--[if lte IE 7]> lte is less than or equal
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by vangogh; 10-17-2008 at 08:10 PM..
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 10-18-2008, 07:28 AM Re: Conditional Comments?
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Quote:
Originally Posted by vangogh View Post
Abel you realize we now have to throw you out of the club. I think using the hack invalidates your membership card. I'll have to check the documentation.
Should I just go ahead and change my user title from '$frontend->developer' to 'banned' now?
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 10-18-2008, 11:16 AM Re: Conditional Comments?
LadynRed's Avatar
Defies a Status

Posts: 10,016
Location: Tennessee
Trades: 0
LOL
The trouble with using a hack is that it's likely to break when the next version of IE comes along - as this one most likely will with IE8. Conditional comments aren't a hack since you are deliberately targeting ONLY the browser that needs the bug fixes. I see it this way - a hack is like a sledgehammer whereas using conditional comments are an exacto knife
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 10-18-2008, 12:05 PM Re: Conditional Comments?
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
I doubt this one will break with IE8, to be honest. It is an extremely well known bug. This depends on your definition of "break", however. I am assuming that most of the rules we are sending to IE7 won't need to be sent to IE8, so when Microsoft fixes the bug, the pages I create will correctly not send the rule to IE8.

If that sounds too risky, keep in mind the _underscore hack. This was a popular and well known bug that people used to target IE6 and below. When IE7 came about, Microsoft fixed the bug and IE7 simply ignored statements beginning with an underscore, as it should. Now, IE6 can be safely targeted this way, as we are totally sure that this bug will not reoccur in the future. I predict that the same thing will happen with the *bug.

Hopefully, IE8 will be so good, that we won't ever need to send special rules to it. I'm hopeful they can do it.
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 10-18-2008, 08:22 PM Re: Conditional Comments?
LadynRed's Avatar
Defies a Status

Posts: 10,016
Location: Tennessee
Trades: 0
They say IE8 will be standards compliant - and it HAS passed the Acid2 test, so that should help us all a great deal. Unfortunately, until earlier versions die completely, we're still going to have to deal with them.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 10-19-2008, 12:40 AM Re: Conditional Comments?
Sean@WMS's Avatar
Skilled Talker

Posts: 52
Name: Sean Connors
Location: Eureka, CA USA
Trades: 0
Hi Rolda,

I'm rather ambivalent about this one, but here is my two cents:

I think your main problem is that you are rather working against youself between your CSS and your markup. That is, you seem to have a decent handle on CSS, but then you are using all kinds of tables to lay out your stuff vis markup instead of CSS. You should really back up your CSS prowess with learning the XMTL that goes with it, kill your tables, and start using div's & CSS to get things where you want them.

While I can't seem to pin point what is throwing things off here, I can tell you that this could be handled much better with divs than with tables.

I would also caution you to at least design for FF, Google Chrome, Saffari, etc. first and then look at IE 7 & 6. Generally, if you get your design dialed in well for FF, etc, it will hold on IE7 too and you may only have a hair-puller on IE 6.

With all of that said, here is an example of your page with a conditional comment used for IE 6 & 7. I generally avoid this sort of thing at all costs m'self, but as I don't expect you're going to work your way out of tables soon, have a look here: http://www.wmsmerchantservices.com/t...p/roofrack.htm

Essentially, I added this:

Code:
<style type="text/css">
.fix-header {
 margin-top:7px
}
</style>
<!--[if lte IE 7]>
<style type="text/css">
.fix-header {
 margin-top:0
}
</style>
<![endif]-->
__________________
Web Merchant Services

Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE
Sean@WMS is offline
Reply With Quote
View Public Profile Visit Sean@WMS's homepage!
 
Old 10-20-2008, 01:05 PM Re: Conditional Comments?
rolda hayes's Avatar
Wannabe Adventurer...

Posts: 960
Name: Darren
Location: England
Trades: 0
Hi Sean,

I agree with you totally about using the tables as well as the CSS -

The problem I have is the client (my boss...) will be updating the pages and absolutely refuses to have a css layout because he has been tinkering with sites for years using tables....

I've convinced him that a CSS menu is better so unfortunately, I have to use the tables below that for his updates - crazy I know but I cant do anything about it...
__________________
I Just a test to see what happens...
Please login or register to view this content. Registration is FREE

"Let us be thankful for the fools. But for them the rest of us could not succeed..."
rolda hayes is offline
Reply With Quote
View Public Profile
 
Old 10-20-2008, 02:51 PM Re: Conditional Comments?
Sean@WMS's Avatar
Skilled Talker

Posts: 52
Name: Sean Connors
Location: Eureka, CA USA
Trades: 0
Quote:
Originally Posted by rolda hayes View Post
Hi Sean,

I agree with you totally about using the tables as well as the CSS -

The problem I have is the client (my boss...) will be updating the pages and absolutely refuses to have a css layout because he has been tinkering with sites for years using tables....

I've convinced him that a CSS menu is better so unfortunately, I have to use the tables below that for his updates - crazy I know but I cant do anything about it...
Ah yes. The old "make me do something against what I'd advise just because you're the hand that feeds me." What can one do?

Anyways, I hope the workaround I posted works for you.
__________________
Web Merchant Services

Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE
Sean@WMS is offline
Reply With Quote
View Public Profile Visit Sean@WMS's homepage!
 
Reply     « Reply to Conditional Comments?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.53999 seconds with 12 queries