Not logged in. · Lost password · Register
Forum: General Help and Support Templates and Layout RSS
Internet Explorer (IE) specific CSS
Avatar
hArpanet #1
Member since Feb 2013 · 17 posts
Group memberships: Members
Show profile · Link to this post
Subject: Internet Explorer (IE) specific CSS
Could some kind person please point me in the direction of instructions about creating browser specific CSS styles in templates?

In particular I want some IE specific settings.

I can see existing .css files have entries like #IE7 but what if I want to apply a style to all versions of IE not just 7?

Cheers.
Avatar
turnermm (Moderator) #2
Member since Oct 2009 · 4161 posts · Location: Canada
Group memberships: Global Moderators, Members, Super Mods
Show profile · Link to this post
The solution is to create a separate style sheet for IE.  Since the template is a php file, you can check the user_agent string and output the appropriate style sheet.

<?php
if(preg_match("/MSIE/",$_SERVER['HTTP_USER_AGENT']) {
   tpl_includeFile('ie.css')
}
else {
 tpl_includeFile('the_rest.css')
}
?>

Place these alternative css files in your template's root directory.
Myron Turner
github: https://github.com/turnermm
plugins, templates: http://www.mturner.org/devel
Avatar
ach (Administrator) #3
Member since May 2006 · 1896 posts · Location: Folkestone, UK
Group memberships: Administrators, Members, Super Mods, Wiki Managers
Show profile · Link to this post
This is not a DokuWiki-specific question and all solutions you'll find on the internet will apply. There are several solutions, but the best on IMHO is the one I use in the starter template (and which is therefore also used in the dokuwiki template):
See the explanation in the comments of its main.php: https://github.com/selfthinker/dokuwiki_template_starter/b…

A slight variation of that is also used by the html5 boilerplate.
It uses Conditional Comments to set certain classes you can use in any CSS files to target specific IE versions.

The solution turnermm posted is one of the many solutions, but a really bad one. It uses browser sniffing, which is considered bad practice and might be punished by search engines. And in the DokuWiki-specific case it also means that you wouldn't be able to make use of our CSS dispatcher/preprocessor which would result in lost functionality and also more http requests.
Avatar
hArpanet #4
Member since Feb 2013 · 17 posts
Group memberships: Members
Show profile · Link to this post
Thanks all, I've updated the css devel page (https://www.dokuwiki.org/devel:css) with your recommendations.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
Imprint
This board is powered by the Unclassified NewsBoard software, 20150713-dev, © 2003-2015 by Yves Goergen
Current time: 2018-07-17, 15:30:18 (UTC +02:00)