gpt4 book ai didi

javascript - 我的 CSS 仅应用于单个页面而不是所有页面 CodeIgniter

转载 作者:太空宇宙 更新时间:2023-11-04 10:39:43 25 4
gpt4 key购买 nike

我正在使用 Codeigniter 框架创建一个简单的网站。我还下载了响应式 HTML5 模板。问题在于 CSS 仅应用于站点的基本 URL。但是当我访问其他页面时,没有应用 CSS。请参阅下面的屏幕截图。

Controller->Pages.php

<?php
defined('BASEPATH') OR exit('No direct script access allowed');


class Pages extends CI_Controller {

function index()
{
if ( ! file_exists(APPPATH.'/views/index.php'))
{
// Whoops, we don't have a page for that!
show_404();
}
$this->load->view('header');
$this->load->view('index');
$this->load->view('footer');
}

function about()
{
if ( ! file_exists(APPPATH.'/views/about.php'))
{
// Whoops, we don't have a page for that!
show_404();
}
$this->load->view('header');
$this->load->view('index');
$this->load->view('footer');
}
}

查看->Header.php

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<!DOCTYPE HTML>

<html>
<head>
<title>Official Website of Barangay Canlubang</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<link href='http://fonts.googleapis.com/css?family=Roboto+Condensed:700italic,400,300,700' rel='stylesheet' type='text/css'>
<!--[if lte IE 8]><script src="js/html5shiv.js"></script><![endif]-->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="<?php echo base_url();?>js/skel.min.js"></script>
<script src="<?php echo base_url();?>js/skel-panels.min.js"></script>
<script src="<?php echo base_url();?>js/init.js"></script>
<noscript>
<link rel="stylesheet" href="<?php echo base_url();?>css/skel-noscript.css" />
<link rel="stylesheet" href="<?php echo base_url();?>css/style.css" />
<link rel="stylesheet" href="<?php echo base_url();?>css/style-desktop.css" />
</noscript>
<!--[if lte IE 8]><link rel="stylesheet" href="css/ie/v8.css" /><![endif]-->
<!--[if lte IE 9]><link rel="stylesheet" href="css/ie/v9.css" /><![endif]-->
</head>

View 中的 index.phpabout.php 仅包含显示内容的 HTML 标记。

最佳答案

您没有type="text/css"并删除 <noscript> <noscript>

<noscript>
<link rel="stylesheet" href="<?php echo base_url();?>css/skel-noscript.css" />
<link rel="stylesheet" href="<?php echo base_url();?>css/style.css" />
<link rel="stylesheet" href="<?php echo base_url();?>css/style-desktop.css" />
</noscript>

更改为

<head>
// Meta
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />

// Title
<title>Official Website of Barangay Canlubang</title>

// CSS
<link type="text/css" rel="stylesheet" href="<?php echo base_url();?>css/skel-noscript.css" />
<link type="text/css" rel="stylesheet" href="<?php echo base_url();?>css/style.css" />
<link type="text/css" rel="stylesheet" href="<?php echo base_url();?>css/style-desktop.css" />

// Scripts
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="<?php echo base_url();?>js/skel.min.js"></script>
<script src="<?php echo base_url();?>js/skel-panels.min.js"></script>
<script src="<?php echo base_url();?>js/init.js"></script>

<!--[if lte IE 8]><script src="js/html5shiv.js"></script><![endif]-->
<!--[if lte IE 8]><link rel="stylesheet" href="css/ie/v8.css" /><![endif]-->
<!--[if lte IE 9]><link rel="stylesheet" href="css/ie/v9.css" /><![endif]-->
</head>

关于javascript - 我的 CSS 仅应用于单个页面而不是所有页面 CodeIgniter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35907164/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com