【问题标题】:css not working on code ignitercss不能在codeigniter上工作
【发布时间】:2016-05-09 17:24:38
【问题描述】:

我最近调试了我的标题css和js连接上的所有错误,不再有错误,但css仍然无法正常工作。但是我的视图格式发生了变化,但不是我想要的。

登录.php

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

class Login extends CI_Controller {


    public function index(){


        $data['main_content'] = 'login_view';
        $this->load->view('includes/viewtemplates',$data);



    }

viewTemplates.php

<?php $this->load->view('includes/header'); ?>
<?php $this->load->view($main_content); ?>
<?php $this->load->view('includes/footer'); ?>

header.php

<!--DOCTYPE html-->

<html lang="en">


<head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>Login</title>
        <link rel="stylesheet" href="<?php echo base_url();?>public/css/bootstrap-responsive.min.css" type="text/css" media="screen" title="no title" charset="utf-8">
        <link rel="stylesheet" href="<?php echo base_url();?>public/css/style.css" type="text/css" media="screen" title="no title" charset="utf-8">

        <script src="<?php echo base_url();?>public/js/jquery.js"></script>
        <script src="<?php echo base_url();?>public/js/bootstrap.js"></script>
</head>

<body>

<header>
</header>

bootstrap-responsive.min.css

 body {

    background: #F0F0F0 ;
    margin: 0;
    padding: 0;
    font-family: 'times-new roman';

 }

#login_form {

    width: 300px;
    background: 3333FF;
    border: 1px solid white;
    margin: 100px auto 0;
    padding: 1em;
    -moz-border-radius:  4px;
    -webkit-border-radius: 4px;
    border-radius: 4px;
}

h1, h2, h3, h4, h5 {

    margin-top = 0;
    text-align: center;
    color: 000033;
    text-shadow: 0 1px 0;
}

【问题讨论】:

  • 检查路径是否正确
  • 你的 base_url 是什么?你应该检查路径是否正确。
  • 我最近遇到了路径错误。我已经修好了。所以我还没有任何想法为什么它不起作用。我是设置代码点火器的新手。

标签: php html css twitter-bootstrap


【解决方案1】:

确保您必须在控制器或 autoload.php 中加载 URL Helper 类,因为要使用 base_url()(简写),您需要加载 URL Helper

$this->load->helper('url');

比你可以使用简写base_url():

<?php echo base_url();?>

我没有看到您的控制器中加载了 URL 帮助程序。

同时检查HTML查看源代码并点击URL你会得到更好的理解。


您还可以检查base_url() 中是否可用的结尾斜线/

如果您的 URL 如下所示,这也不起作用:

<script src="<?php echo base_url();?>public/js/jquery.js"></script> 
// example.compublic/js...

【讨论】:

  • $autoload['helper'] = array('url','form');我已经有 url 自动加载。
  • 我在元素部分找到了这个不是我的 CSS。
  • ` element.style { } indexmedia="screen" body { 背景:白色;字体系列:arial; } indexmedia="screen" @media (max-width: 979px) body { padding-top: 0; } indexmedia="screen" @media (max-width: 767px) body { padding-right: 20px;填充左:20px; } 用户代理样式表体 { 显示:块;边距:8px; }`
  • @kev_m: echo base_url();检查网址是什么?
  • 网址是什么?什么的网址?
【解决方案2】:

网站图片存在问题,无法正确加载
您可以为此使用基本标签(您需要在&lt;head&gt;中添加&lt;base&gt;标签)...

<base href="<?php echo base_url();?>public/">

并确保图像文件在公共目录中

【讨论】:

  • 所以将 标签更改为 ??
  • 赞这个&lt;base&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt; &lt;title&gt;Login&lt;/title&gt; &lt;link rel="stylesheet" href="&lt;?php echo base_url();?&gt;public/css/bootstrap-responsive.min.css" type="text/css" media="screen" title="no title" charset="utf-8"&gt; &lt;link rel="stylesheet" href="&lt;?php echo base_url();?&gt;public/css/style.css" type="text/css" media="screen" title="no title" charset="utf-8"&gt; &lt;script src="&lt;?php echo base_url();?&gt;public/js/jquery.js"&gt;&lt;/script&gt; &lt;script src="&lt;?php echo base_url();?&gt;public/js/bootstrap.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;/base&gt;
  • &lt;head&gt;&lt;base href="&lt;?php echo base_url();?&gt;public/"&gt;&lt;/head&gt;
猜你喜欢
  • 2015-08-11
  • 2016-11-16
  • 2012-11-26
  • 2015-06-15
  • 2012-05-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多