【问题标题】:Load css on controller function在控制器功能上加载 css
【发布时间】:2018-07-20 07:36:53
【问题描述】:

我在分页 php 上加载资产 css(引导程序和图像)时遇到问题

我的主要/默认页面是 当然,图像和 css 也已加载

http://localhost:8080/iklan/

....
但是当我进入第2页时..

http://localhost:8080/iklan/iklan/index/2


图像和 CSS 引导程序不会显示
...
可能是因为函数索引控制器
$config["base_url"] = base_url().'/iklan/index';

我的 CSS 在资产上

C:\xampp\htdocs\iklan\aset

当我的图像打开时

C:\xampp\htdocs\iklan\upload_iklan

我像这样在视图中调用 css
<link rel="stylesheet" href="aset/bower_components/bootstrap/dist/css/bootstrap.min.css">

有人知道如何加载css吗?

【问题讨论】:

  • 尝试将$config['base_url']更改为base_url().'/index';
  • 不幸的是它变成了“找不到对象!”或“未找到您请求的页面。”
  • css 文件在哪里?你如何在你的 html 代码中调用它?
  • 在:C:\xampp\htdocs\iklan\aset 。我对: C:\xampp\htdocs\iklan\application\views 的看法。我这样称呼它

标签: php sql codeigniter model-view-controller pagination


【解决方案1】:

更改您的基本网址

$config["base_url"] = base_url().'/iklan/index';

$config['base_url'] = site_url('/iklan/index');

【讨论】:

  • 哦,非常感谢你......这已经成功......愿上帝保佑你
  • 哈哈,我很高兴
  • 谢谢。上帝保佑你
【解决方案2】:

希望对您有所帮助:

首先在config.php中设置你的base url

$config['base_url']= 'http://localhost/iklan/';

并使用site_url()加载cssjs

site_url() 返回您在配置文件中指定的站点 URL。 index.php 文件会自动添加到 URL 中

<link rel="stylesheet" href="<?=site_url('aset/bower_components/bootstrap/dist/css/bootstrap.min.css');?>" >

注意:确保你的css文件路径正确

更多:https://www.codeigniter.com/user_guide/helpers/url_helper.html

【讨论】:

  • 是的,这也有效。谢谢你帮助我:)。刚刚用了"href="=site_url" 哈哈
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-09-24
  • 2017-09-18
  • 2016-05-29
  • 2018-09-09
  • 1970-01-01
相关资源
最近更新 更多