Jump to content
xisto Community
Sign in to follow this  
gunbound

Css Stylesheet - "if Ie" Tag Possible?

Recommended Posts

<style type="text/css">#memoryticker{width: 448px;}</style>

So, I've got this as part of the stylesheet for a JavaScript I'm using (I removed the irrelevant parts of the code for this question).

 

When it's at width:448, it aligns itself properly with the image it's next to perfectly - for FireFox

 

When it's at width:450, it aligns itself properly with the image it's next to perfectly - for Internet Explorer

 

Too see what I'm doing, visit this page: http://forums.xisto.com/no_longer_exists/

 

You will see News/Updates. That's an image that's 450px wide. Below that is the Javascript, which in Firefox needs to be 448px wide because it has the 1px border on the sides (1px border * 2 + 448 = 450).

 

IE does not add the border pixels to the width, making it 2 pixels short.

 

I need to make it so that [if IE], the style will be width:450

 

Can I use an [if IE] tag in there somehow?

Share this post


Link to post
Share on other sites

I think you can, Chech with the admins/mods.I have no idea, Accually i di but just cant remember.Thanks,FFC Webmaster,Asad Haider.

Share this post


Link to post
Share on other sites

It uses javascript. Here it is:

 

<script language="javascript">if (navigator.appVersion.indexOf("MSIE")!=-1) {document.write ("<style type=\"text/css\">")document.write("#memoryticker{")document.write("width: 450px;")document.write("}")document.write("<\/style>")} else {document.write ("<style type=\"text/css\">")document.write("#memoryticker{")document.write("width: 450px;")document.write("}")document.write("<\/style>")}</script>

If the browser is any IE version it write's the width having 450px. The user can have any other browser } else { and the width will be set to 448px. If you wish to change the else bit to do Firefox only I believe you to change it to this:

 

From:

 

} else {

 

To:

 

} elseif (navigator.appVersion.indexOf("FF")!=-1) {

 

This may not be correct but I believe so -_-

 

Do you understand? Don't hesitsate to reply if you don't

Share this post


Link to post
Share on other sites

I hate to have people think I'm spamming but I made an error when copying the code from on another.

 

document.write("width: 450px;") in the } else { sector should be document.write("width: 448px;") in accordance with what you specified -_-

Share this post


Link to post
Share on other sites

That works. I'm familiar with that method, but was wondering if there was something else I could do. But I've just gone ahead and done it this way. Thanks for the help.

Share this post


Link to post
Share on other sites

When it's at width:448, it aligns itself properly with the image it's next to perfectly - for FireFox

 

When it's at width:450, it aligns itself properly with the image it's next to perfectly - for Internet Explorer

Try this:

#memoryticker{ width: 448px; }html>body #memoryticker{ width: 450px; }

Since IE doesn't recognise many CSS selectors you can make hacks like that. IE doesn't understand html>body, so it just ignores the style rule. But Firefox understands it, and in CSS the last rule is the one that counts, Firefox just ignores the first rule.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.