Trying to add an image logo inside a boostrap logo

五迷三道 提交于 2021-01-28 21:53:37

问题


I have the following nav bar code and as you can see I have tried to add an image as a logo instead of text. The below doesn't work.

<li class="nav-item">
    <a class="nav-link active" aria-current="page" img src="https://www.pngfind.com/pngs/m/572-5720766_eye-logos-png-image-with-transparent-background-eyelid.png">Home</a>
</li>
        

Also tried:

 <a class="nav-link active" aria-current="page" >img src="https://www.pngfind.com/pngs/m/572-5720766_eye-logos-png-image-with-transparent-background-eyelid.png"</a>

Attempt 3

<li class="nav-item">
          <a class="nav-link active" aria-current="page" img src="https://www.pngfind.com/pngs/m/572-5720766_eye-logos-png-image-with-transparent-background-eyelid.png"</a>
</li>

I'd also like to know where to go/what docs to use to find the right syntax for these things


回答1:


You need to place the logo within the a tag with a class of navbar-brand as an img tag.

You didn't write the syntax of an img tag correctly. The correct syntax is <img src="" alt=""/>

Full example:

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet"/>
      
<nav class="navbar navbar-expand-md navbar-light bg-light fixed-top">
        <a class="navbar-brand" href="/"><img src="https://www.pngfind.com/pngs/m/572-5720766_eye-logos-png-image-with-transparent-background-eyelid.png" class="d-inline-block align-top" loading="lazy" style="width: 100px;"/></a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
          <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
          <ul class="navbar-nav">
            <li class="nav-item">
              <a class="nav-link" href="/">HOME</a>
            </li>
          </ul>
        </div>
      </nav>



回答2:


you're mistaken in the img tag just set it as :

<li class="nav-item">
  <a class="nav-link active" aria-current="page"> 
    <img src="https://www.pngfind.com/pngs/m/572-5720766_eye-logos-png-image-with-transparent-background-eyelid.png" alt="home"/>
   </a>
</li>


来源:https://stackoverflow.com/questions/65615009/trying-to-add-an-image-logo-inside-a-boostrap-logo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!