我已經在 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;>
這樣當您更改視圖的路徑時,徽標的路徑就無需更改。

料青山看我應如是
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>

三國紛爭
TA貢獻1804條經驗 獲得超7個贊
在標題中嘗試此代碼
<body>
<img src="<?php echo base_url();?>imag/logo.png" height="28px" alt="">
</body>
- 3 回答
- 0 關注
- 172 瀏覽
添加回答
舉報
0/150
提交
取消