![]() |
what method do you use with php when displaying a stylesheet?
this is how i display a style sheet for whatever browser that opens the page.
Code:
function style() {whats another way of doing this?? thanks |
you could just use HTML conditional statements:
<!--[if IE]> <link href="/includes/ie-fixes.css" rel="stylesheet" type="text/css" /> <![endif]--> there is also get_browser() for php: $browser = get_browser(null, true); print_r($browser); personally I use the html method.. i've used the php method and i like it but it won't work on all servers if it's not setup properly. |
I usually use a main style sheet which holds all styles that good browsers render properly and for the retarded browsers i use conditional statements to overwrite specific styles:
HTML Code:
<link rel="stylesheet" href="main.css" type="text/css" /> |
thanks, but what do you put for other browsers?
like firefox, chrome, etc do you have to write a javascript for each browser? cause i noticed chrome acts a little different since its a mozilla engine. |
the conditionals only work for IE (I can't find anywhere that would suggest different). The way I work this out is to develop for FF/Safari/Opera. Then make it work in IE. Those three seem to work better with standard code. IE really needs the shims to get everything to look correct. And these three cover the basic html render engines. These same rules apply for JavaScript too..
here is a link for the conditionals.. http://www.dedestruct.com/2008/04/03...onal-comments/ |
Chrome is built on webkit, which is the very same engine as safari. General rule of thumb (i find anyway) if it works in chrome, it will generally work in safari.
|
how about i start working on a project to make a major reset either stylesheet or php file that will be included into a page and make all major browsers all work the same as a primary browser in this case be firefox. if anyone is interested in helping out let me know.
we gotta end this problem. |
All you need to do is design for Firefox, correct for IE using conditional statements, and that's it.
There is no need what so ever to have a separate css file for each browser, because if it works in FF, it should work in all modern browsers. Browser sniffing is not used now. Especially as some browsers can pretend to be other browsers and thus feed your script duff data. |
The easiest way is to use a framework really. The frameworks handles the mass reset etc.
Read this thread http://www.talkphp.com/xhtml-html-cs...-bluetrip.html for a good framework. |
If you actually know css you can almost always get it down to 1 style sheet and not have to worry about this at all. However every now and then ie will act up and you can just use the html conditions as stated above to fix this.
The best way to avoid this is to have all 4 browsers up at once (FF/Opera/Chrome/IE7) and after every css change refresh the page one all 4 until you get it right in all 4. Then this whole mess can be avoided. It might take a little bit longer but its much easier once it works. |
| All times are GMT. The time now is 01:36 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0