Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSS and ASP - two tastes that don't go great together?

Status
Not open for further replies.

jwh123

Technical User
Mar 29, 2002
13
US
I'm trying to incorporate some if...then asp statements into a css stylesheet so as to accomodate netscape's weirdness. Unfortunately, the vbscript in the stylesheet doesn't seem to be read by the page. It's pretty simple stuff (I took most of the browser detect script from webmonkey), but I can't get it to work. The problem is the linespacing in NS4.x, which looks strange unless adjusted. Any tips are much appreciated!!!!


the stylesheet is
Thanks!

Cheers,
Jeff
 
Jeff,

You can create two different style sheets, one for IE and one for Netscape. Then use the appropriate style sheet for each user based on your browser detecting code.
 
Just create two seperate css files, and then make in the
ASP document a <b>if then</b> statement, should work. [bobafett] BobbaFet [bobafett]

Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com
 
Making two CSS files is a good way and then just do a browser sniff to determin which one to be used...or you can create a .js file with a netscape version and an IE version. I did this and created variables at the top of the file that determind font-family, font-size etc etc.

eg:

myFontIE = helvetica
myFontSizeIE = 12px
myFontNS = helvetica
myFontSizeNS = 14px

Obviously there is other code that writes out the CSS code
like:

var myCSS = &quot;.myStyle{font-family:&quot;+myFontIE+&quot;; font-size:&quot;+myFontSizeIE+&quot;;}&quot;
myCSS += &quot;.myOtherStyle{font-family:&quot;+myFontIE+&quot;; font-size:&quot;+myFontSizeIE+&quot;;}&quot;

document.write(myCSS_IE);


Having the variables at the top makes it easier in the long run to quickly change attributes.

One thing about using this method is that it can be a pain in the arse adding new classes and the file may get too large in which case using individual CSS's may be the better option but just more hassel to change as you would have to change both CSS pages every time.

Dont you just LOVE netscape for making life easy!! :S

Hope this has maybe given you another idea.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top