为了账号安全,请及时绑定邮箱和手机立即绑定

有没有办法在许多页面 php 中显示徽标?

有没有办法在许多页面 php 中显示徽标?

PHP
九州编程 2021-11-13 16:50:49
我已经在 header.php 上写了一个代码 logo/img但是,当我要刷新时,不想显示徽标。有解决办法吗?我使用了 bootstrap 4,简单的 html 和 css。我已经尝试了很多次,但总是失败。在任何功能中,徽标已经显示,但在“tambahalternatif”中不想显示这是我的控制器:<?php    class Alternatif extends CI_Controller{        public function __construct()        {            parent::__construct();            $this->load->model('Alternatif_model');            $this->load->library('form_validation');        }        public function index()        {            $data ['judul'] = 'Isi Alternatif';            $data ['alternatif'] = $this->Alternatif_model->getAllAlternatif();            if($this->input->post('key')){                $data['alternatif'] = $this->Alternatif_model->cariDataAlternatif();            }            $data['hasil'] = $this->Hitung(); //Manggil fungsi Hitung()             $this->load->view('templates/header',$data);            $this->load->view('alternatif/index', $data);            $this->load->view('templates/footer' );        }        public function tambahalternatif()        {            $data['judul'] = 'Form Tambah Data Alternatif';            // $this->form_validation->set_rules('idclient','ID','required|numeric');            $this->form_validation->set_rules('namaalt','NAMA','required');            if ($this->form_validation->run() == FALSE) {            $this->load->view('templates/header', $data);            $this->load->view('alternatif/tambahalternatif');            $this->load->view('templates/footer');        } else {            $this->Alternatif_model->tambahDataAlternatif();            $this->session->set_flashdata('flash','Berhasil');            redirect('alternatif');         }标题视图<nav class="navbar navbar-expand-lg navbar-light bg-light navbar-fixed-top ml-right"><div class="container"><a class="navbar-brand" href="<?=base_url(); ?>" ><img class="logo" src="./img/logo.png" height="28px;" padding="2px 10px;></a>   我希望图像(徽标)将显示在“tambahalternatif”中,但图像(徽标)仅显示在“alternatif”中
查看完整描述

3 回答

?
慕娘9325324

TA贡献1783条经验 获得超4个赞

使用基本路径而不是绝对路径。

代替

<img class="logo" src="./img/logo.png" height="28px;" padding="2px 10px;>

用下面的线

<img class="logo" src="<?php echo base_url(); ?>img/logo.png" height="28px;" padding="2px 10px;>

这样当您更改视图的路径时,徽标的路径就无需更改。


查看完整回答
反对 回复 2021-11-13
?
料青山看我应如是

TA贡献1772条经验 获得超8个赞

***Try this one & let us know is it ok now.

Thanks.***


<nav class="navbar navbar-expand-lg navbar-light bg-light navbar- 

fixed-top ml-right">


<div class="container">


    <a class="navbar-brand" href="<?= base_url(); ?>" >

        <img class="logo" src="<?= base_url().'img/logo.png'; ?>" 

        height="28px" padding="2px 10px">

    </a>


</div>


</nav>


查看完整回答
反对 回复 2021-11-13
?
三国纷争

TA贡献1804条经验 获得超7个赞

在标题中尝试此代码


<body>

<img src="<?php echo base_url();?>imag/logo.png" height="28px" alt="">  

</body>


查看完整回答
反对 回复 2021-11-13
  • 3 回答
  • 0 关注
  • 153 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信