You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

头部Logo链接正确却无法显示,是否受Bootstrap类影响?

Let's break down why your logo isn't showing up and fix it step by step—here are the key issues and solutions:

1. Local Absolute Paths Don't Work in Browsers

Your CSS uses a full Windows file path (C:\Users\Gianpa\...) for the logo image. Browsers interpret this as an invalid URL protocol instead of a local file reference, so the image fails to load.

Fix: Use a relative path instead. Assuming your project structure looks like this:

sito prova/
├── css/
│   ├── bootstrap.min.css
│   └── banco prova css.css
├── images/
│   └── logo.jpg
└── index.html

Update your background URL to point relative to your CSS file:

background: url('../images/logo.jpg');

2. Bootstrap's navbar-brand Default Styles Are Interfering

The built-in navbar-brand class has styles that can hide or distort your logo:

  • It includes default padding: 15px 15px which can push your background image out of view
  • The parent .navbar has min-height: 50px, which is way smaller than your 150px tall logo, causing the logo to be cut off or hidden entirely

Fix: Override these styles in your custom CSS:

#logoheader {
  background: url('../images/logo.jpg') no-repeat center center; /* Add no-repeat + centering */
  background-size: contain; /* Ensure the entire logo fits the container */
  width: 150px;
  height: 150px;
  margin: 20px 20px 10px 0;
  padding: 0; /* Remove default padding */
}

/* Adjust navbar height to fit your logo */
.navbar {
  min-height: auto; /* Override Bootstrap's 50px minimum height */
}

3. Missing Background Display Properties

Without background-repeat: no-repeat, your logo might tile repeatedly and look broken. Adding background-size: contain ensures the full logo is visible within your defined width and height.

Quick Debugging Tip

Right-click the logo area in your browser and select "Inspect" to open DevTools:

  • Check the Styles tab to confirm the background image path is correct (look for a broken image icon if the path is wrong)
  • Verify the width and height of #logoheader are being applied correctly
  • Ensure no other styles are setting display: none or visibility: hidden on the element

内容的提问来源于stack exchange,提问作者Enrico

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 09:28:11