简体   繁体   English

将自定义CSS导入joomla

[英]Importing custom CSS into joomla

I've created a custom template for Joomla and in my CSS I've got a number of style sheets that activate at a certain pixel dimension, like so: 我为Joomla创建了一个自定义模板,在CSS中,我获得了许多可在某个像素尺寸处激活的样式表,如下所示:

<link rel="stylesheet" media="(min-width:761px) and (max-width:1080px)" href="css/720.css">

Now if I'm to transfer it to Joomla under the PHP for the template I'd write it like: 现在,如果要将模板下的PHP转移到Joomla,则可以这样写:

$doc->addStyleSheet('templates/' . $this->template . '/css/720.css');

But the issue I'm having is how to I add the 'media' tags to the PHP, otherwise the style sheet will just activate regardless, not under its correct dimensions? 但是我遇到的问题是如何在PHP中添加“ media”标签,否则样式表将被激活,无论其尺寸是否正确?

From https://docs.joomla.org/JDocument/addStyleSheet https://docs.joomla.org/JDocument/addStyleSheet

void addStyleSheet( $url, $type, $media, $attribs )

You don't need the type setting so you set that to null then set the $media variable to the value that you would put in that attribute. 您不需要类型设置,因此可以将其设置为null然后将$media变量设置为要放入该属性的值。 For example 例如

$doc->addStyleSheet(
    'templates/' . $this->template . '/css/720.css',
    null,
    '(min-width:761px) and (max-width:1080px)'
);

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

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