Jul 25, 2008

Css Stylesheet - "if Ie" Tag Possible?

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > CSS (Cascading Style Sheets)

free web hosting

Css Stylesheet - "if Ie" Tag Possible?

gunbound
CODE
<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://gunbound.trap17.com/phpBB

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?

 

 

 


Reply

mbd5882
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.

Reply

electriic ink
It uses javascript. Here it is:

CODE

<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 smile.gif

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



 

 

 


Reply

electriic ink
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 smile.gif

Reply

gunbound
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.

Reply

bjrn
QUOTE(gunbound @ May 1 2005, 05:58 PM)
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:
CODE
#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.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. Searching Video's for css, stylesheet, tag
advertisement

Your Ad Here


Css Stylesheet - "if Ie" Tag Possible?



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE