在我的 joomla 模板中,我删除了 index.php 头部中样式表的链接,而是添加了以下 jquery 代码来选择基于屏幕宽度的样式表
<script type="text/javascript">
$(document).ready(function()
{
if (screen.width <= 1024)
{
$('head').append('<link rel="stylesheet" href="style2.css" type="text/css"/>');
}
}
$(document).ready(function()
{
if (screen.width > 1024)
{
$('head').append('<link rel="stylesheet" href="template.css" type="text/css/>');
}
}
</script>
当我在浏览器中加载网站时,没有使用样式表。我不明白出了什么问题。提前致谢
EvilP,感谢您的回复,是的,css 与 index.php 位于同一位置