繁体   English   中英

Internet Explorer CSS:Joomla自定义模板

[英]Internet explorer css: Joomla Custom template

我试图添加一个名为ie.css的仅Internet Explorer的CSS文件。

我已经构建了一个简单的自定义joomla模板,除了....通常的罪魁祸首IE,它在所有浏览器中都可以正常工作!

我已经将ie.css添加到css文件夹中,我正在努力使该文件只能从IE读取。 这是我的.php文件:

 <?php $doc = JFactory::getDocument(); $doc->addStyleSheet('templates/' . $this->template . '/css/main.css'); $doc->addStyleSheet('templates/' . $this->template . '/css/header.css'); $doc->addStyleSheet('templates/' . $this->template . '/css/footer.css'); $doc->addStyleSheet('templates/' . $this->template . '/css/container.css'); $stylelink = '<!--[if lte IE 9]>' ."\\n"; $stylelink .= '<link rel="stylesheet" href="/css/ie.css" />' ."\\n"; $stylelink .= '<![endif]-->' ."\\n"; $document = JFactory::getDocument(); $document->addCustomTag($stylelink); $doc->addScript('/templates/' . $this->template . '/java/java.js', 'text/javascript'); ?> <!DOCTYPE html> <html> <head> <jdoc:include type="head" /> <!--[if gte IE 9]> <style type="text/css"> .gradient { filter: none; } </style> <![endif]--> <!--[if IE]> <link rel="stylesheet" type="text/css" href="css/ie.css" /> <![endif]--> </head> <body> <div id="back"> <jdoc:include type="modules" name="background_image" style="none" /></div> <div class="wrapper"> <div id="logo"><jdoc:include type="modules" name="logo" style="none" /></div> <div class="menu"> <jdoc:include type="modules" name="nav-main" style="none" /> </div> <div class="container"> <jdoc:include type="component" /> <div id="home_content_top"> <jdoc:include type="modules" name="content_area_one" style="none" /> </div> <div id="home_discount"> <jdoc:include type="modules" name="content_area_two" style="none" /> </div> <div id="footer"> <jdoc:include type="modules" name="footer" style="none" /> </div> </div> </div> </body> </html> 

我哪里出问题了?

尝试调用CSS文件时,您尚未定义基本路径,因此当前正在尝试查找:

www.example.com/css/ie.css

当实际路径是:

www.example.com/templates/YOUR_TEMPLATE/css/ie.css

另外,我不会使用PHP来呈现条件语句。 不用它会更清洁,因此删除所有这些:

$stylelink = '<!--[if lte IE 9]>' ."\n";
$stylelink .= '<link rel="stylesheet" href="/css/ie.css" />' ."\n";
$stylelink .= '<![endif]-->' ."\n";
$document = JFactory::getDocument();
$document->addCustomTag($stylelink);

在您的<head>标记内添加以下内容:

<!--[if lte IE 9]>
    <link rel="stylesheet" href="templates/<?php echo $this->template; ?>/css/ie.css" />
<![endif]-->

只是一个旁注。 您不需要调用JFactory::getDocument()两次,只需调用一次,就像在代码顶部一样。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM