我为 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 文件?或者就在头部关闭标签之前?
提前致谢。
最佳答案
试试这个,
这不会在 head 标签
内添加样式表,但它会在 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);
希望它的作品..
关于css - 在模板 CSS 之后或头部关闭标签之前在 Joomla 中添加 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23931024/