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

我已经在 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”中


九州编程
浏览 154回答 3
3回答

慕娘9325324

使用基本路径而不是绝对路径。代替<img&nbsp;class="logo"&nbsp;src="./img/logo.png"&nbsp;height="28px;"&nbsp;padding="2px&nbsp;10px;>用下面的线<img&nbsp;class="logo"&nbsp;src="<?php&nbsp;echo&nbsp;base_url();&nbsp;?>img/logo.png"&nbsp;height="28px;"&nbsp;padding="2px&nbsp;10px;>这样当您更改视图的路径时,徽标的路径就无需更改。

料青山看我应如是

***Try this one & let us know is it ok now.Thanks.***<nav class="navbar navbar-expand-lg navbar-light bg-light navbar-&nbsp;fixed-top ml-right"><div class="container">&nbsp; &nbsp; <a class="navbar-brand" href="<?= base_url(); ?>" >&nbsp; &nbsp; &nbsp; &nbsp; <img class="logo" src="<?= base_url().'img/logo.png'; ?>"&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; height="28px" padding="2px 10px">&nbsp; &nbsp; </a></div></nav>

三国纷争

在标题中尝试此代码<body><img src="<?php echo base_url();?>imag/logo.png" height="28px" alt="">&nbsp;&nbsp;</body>
打开App,查看更多内容
随时随地看视频慕课网APP