Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/255.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Joomla 2.5-为iPad添加自定义CSS_Php_Html_Css_Joomla_Joomla2.5 - Fatal编程技术网

Php Joomla 2.5-为iPad添加自定义CSS

Php Joomla 2.5-为iPad添加自定义CSS,php,html,css,joomla,joomla2.5,Php,Html,Css,Joomla,Joomla2.5,我想在iPad上查看joomla网站时加载css文件 我使用的joomla版本是2.5 我目前已经为浏览器(如Internet Explorer和Firefox)设置了样式表,但不知道如何告诉网站专门为设备(如iPad)加载css文件 任何帮助都将不胜感激 像这样的东西应该可以做到: <?php $isiPad = (bool) strpos($_SERVER['HTTP_USER_AGENT'],'iPad'); if $isiPad; echo "<link hre

我想在iPad上查看joomla网站时加载css文件

我使用的joomla版本是2.5

我目前已经为浏览器(如Internet Explorer和Firefox)设置了样式表,但不知道如何告诉网站专门为设备(如iPad)加载css文件


任何帮助都将不胜感激

像这样的东西应该可以做到:

<?php
$isiPad = (bool) strpos($_SERVER['HTTP_USER_AGENT'],'iPad');

if $isiPad;    
  echo "<link href='ipad-styles.css' rel='stylesheet' type='text/css'>";
?>

isher的答案是一个很好的方法,但是要导入CSS文件,我会这样做,使用Joomla编码标准:

<?php
$isiPad = (bool) strpos($_SERVER['HTTP_USER_AGENT'],'iPad');

if ($isiPad){    
   $doc = JFactory::getDocument(); //only include if line doesn't already exist
   $doc->addStyleSheet (JURI::root() . "template/template-name/ipad-styles.css" );
}
?>

或者您可以使用此脚本并添加到模板或自定义模块(分配给所有页面):


jQuery(函数($){
var userAgent=navigator.userAgent.toLowerCase();
var regex=new RegExp('ipad','i');
if(userAgent.match(regex)){
$('').appendTo($('head');
}});
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
jQuery(function($){ 
var userAgent = navigator.userAgent.toLowerCase();
var regex = new RegExp('ipad',"i"); 
if(userAgent.match(regex)){
    $('<link href="css/ipad.css" rel="stylesheet" type="text/css"/>').appendTo($('head'));
}});
</script>