Php 样式表在Kohana中不起作用
我尝试了几种方法将.css和.js文件应用于视图php文件。(1) 第一种方式如下所示:Php 样式表在Kohana中不起作用,php,model-view-controller,Php,Model View Controller,我尝试了几种方法将.css和.js文件应用于视图php文件。(1) 第一种方式如下所示: <head> <meta charset="UTF-8" /> <?php echo html::meta('viewport', 'width=980'); ?> <title>A-TRACK Tutoring</title> <?php echo html::link('http://fonts.googleapis.com/css
<head>
<meta charset="UTF-8" />
<?php echo html::meta('viewport', 'width=980'); ?>
<title>A-TRACK Tutoring</title>
<?php echo html::link('http://fonts.googleapis.com/css?family=Open+Sans:300,400,700',
'stylesheet','text/css', FALSE);?>
<?php echo html::link('media/css/atrack.css',
'stylesheet','text/css', FALSE, 'all');?>
</head>
......
</html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=980" />
<title>A-TRACK Tutoring</title>
<?php
if(isset($css)){
foreach($css as $type => $file){
?>
<link type='text/css' href='<?php echo $file ?>' rel='stylesheet' />
<?php
}}
?>
......
</head>
它们都不起作用。有人知道原因吗?谢谢 在示例2中,通过在数组中使用同一个键两次来写入atrack.css值
<head>
<meta charset="UTF-8" />
<?php echo html::meta('viewport', 'width=980'); ?>
<title>A-TRACK Tutoring</title>
<?php echo html::link('http://fonts.googleapis.com/css?family=Open+Sans:300,400,700',
'stylesheet','text/css', FALSE);?>
<?php echo html::link('media/css/atrack.css',
'stylesheet','text/css', FALSE, 'all');?>
</head>
......
</html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=980" />
<title>A-TRACK Tutoring</title>
<?php
if(isset($css)){
foreach($css as $type => $file){
?>
<link type='text/css' href='<?php echo $file ?>' rel='stylesheet' />
<?php
}}
?>
......
</head>
按如下方式更改控制器:
<head>
<meta charset="UTF-8" />
<?php echo html::meta('viewport', 'width=980'); ?>
<title>A-TRACK Tutoring</title>
<?php echo html::link('http://fonts.googleapis.com/css?family=Open+Sans:300,400,700',
'stylesheet','text/css', FALSE);?>
<?php echo html::link('media/css/atrack.css',
'stylesheet','text/css', FALSE, 'all');?>
</head>
......
</html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=980" />
<title>A-TRACK Tutoring</title>
<?php
if(isset($css)){
foreach($css as $type => $file){
?>
<link type='text/css' href='<?php echo $file ?>' rel='stylesheet' />
<?php
}}
?>
......
</head>
public function action_index()
{
$view = View::factory('singleanswer/index');
$view->css = array(
'normal' => 'media/css/atrack.css',
'normal' => 'http://fonts.googleapis.com/css?family=Open+Sans:300,400,700',
);
// Render the view
$this->response->body($view);
}
} // End Welcome
public function action_index()
{
$view = View::factory('singleanswer/index', array("css" => array(
Url::site("media/css/atrack.css"),
'http://fonts.googleapis.com/css?family=Open+Sans:300,400,700',
));
// Render the view
$this->response->body($view);
}
并将您的视图更新为:
<head>
<meta charset="UTF-8" />
<?php echo html::meta('viewport', 'width=980'); ?>
<title>A-TRACK Tutoring</title>
<?php echo html::link('http://fonts.googleapis.com/css?family=Open+Sans:300,400,700',
'stylesheet','text/css', FALSE);?>
<?php echo html::link('media/css/atrack.css',
'stylesheet','text/css', FALSE, 'all');?>
</head>
......
</html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=980" />
<title>A-TRACK Tutoring</title>
<?php
if(isset($css)){
foreach($css as $type => $file){
?>
<link type='text/css' href='<?php echo $file ?>' rel='stylesheet' />
<?php
}}
?>
......
</head>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=980" />
<title>A-TRACK Tutoring</title>
<?php
if(isset($css))
{
foreach($css as $file){
echo "<link type='text/css' href='{$file}' rel='stylesheet' />";
}
}
?>
......
</head>
A轨道辅导