PDA

View Full Version : safari css


chriskq
02-22-2007, 11:14 AM
is there a way to hack a class in css that ONLY mac safari reads.

eg; if u use,
* html .className {
margin: etc etc;
}

only IE will read it.

thankx

davidj
02-22-2007, 11:38 AM
you need to detect the browser using javascript then call in a specific CSS depending on what is detected..


<script type="text/javascript">

var bname=navigator.appName
var build =navigator.appVersion
var buildFloat=parseFloat(build) // build 2.5.6.7.0 will be rounded

switch(bname){

case 'Microsoft Internet Explorer': sheet = '<link href="default1.css" rel="stylesheet" type="text/css" />'; break;

case 'Netscape': sheet = '<link href="default2.css" rel="stylesheet" type="text/css" />'; break;
}

document.getElementById('css').innerHTML = sheet;
</script>
then where you would have your css call...
<link href="default.css" rel="stylesheet" type="text/css" />
Just replace with

<div id="css"></div>Please note i am looking at this from a programmers prospective not a web designers. Some guru will come back with a better solution

domedia
02-22-2007, 12:47 PM
Chris, it seems that a CSS hack specifically for Safari does not exist:
http://centricle.com/ref/css/filters/

ranjan
02-22-2007, 01:21 PM
::root .className {
margin: etc etc;
}

chriskq
02-22-2007, 09:17 PM
thanks guys.

ranjan ill give that go...
its just annoying me coz safari isnt recongising a margin im setting on a class... im sure i can find a work around.

and dj... gaawd i dread the day i start having to do a seperate css for each browser - that means i can charge 3 times as much thou doesnt it... well im sure no client would buy that. roflol.

;)

domedia
02-23-2007, 12:36 PM
gaawd i dread the day i start having to do a seperate css for each browser Nowadays there's no reason you should have to, but 5- 7 years ago it was the standard if you were doing CSS :)