【问题标题】:Add CSS in Joomla after template CSS or before head close tag在模板 CSS 之后或头部关闭标记之前在 Joomla 中添加 CSS
【发布时间】:2014-05-29 10:19:49
【问题描述】:

我为 joomla 3.2 开发了一个组件,我是 adding 一个 CSS 文件。

my_component/views/my_view/tmpl/default.php

$document = JFactory::getDocument();
$document->addStyleSheet("components/my_component/static/css/my_css.css");

它有效,它已加载但“为时过早”。

    <link rel="stylesheet" href="my_project/components/com_ciceron/static/css/styles.css" type="text/css" />
    <link rel="stylesheet" href="my_project/templates/business/font/mavenpro.css" type="text/css" />  
    <link rel="stylesheet" href="my_project/templates/business/css/styles.css" type="text/css" />
    <link rel="stylesheet" href="my_project/templates/business/css/newStyles.css" type="text/css" />
    <link rel="stylesheet" href="my_project/templates/business/css/bootstrap.min.css" type="text/css" />
    <link rel="stylesheet" href="my_project/templates/business/css/font-awesome.min.css" type="text/css" />
</head>

如您所见,我添加的文件是在模板 css 之前添加的,因此会覆盖一些 css 规则。

有什么方法可以在模板 CSS 之后添加一个 CSS 文件?还是就在头部关闭标签之前?

提前致谢。

【问题讨论】:

    标签: css joomla stylesheet joomla3.0 joomla-component


    【解决方案1】:

    试试这个,

    这不会在head tag 内添加样式表,但会在template css 下添加,这意味着无论您从哪里调用此方法,它都会插入样式表。查看底部section

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

    希望它的作品..

    【讨论】:

      猜你喜欢
      • 2019-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-06
      • 1970-01-01
      相关资源
      最近更新 更多