在引导程序导航栏上插入图像

新手上路,请多包涵

我正在尝试在导航栏上设置图像,但我无法正确放置它。

这是 html:

 <nav class="navbar navbar-inverse navbar-fixed-top  ">
  <div class="navbar-header">
    <a class="navbar-brand" href="#">
      <img width="130px" height="70px"src="{% static "series/images/logo.png"%}">
    </a>
    <a class="navbar-brand" href="{% url 'series:index'%}">
      <span class="glyphicon glyphicon-home"></span> | MEGA SERIES  </a>
  </div>
  <ul class="nav navbar-nav">
    <li class="active"><a href="{% url 'series:index'%}">Series</a></li>
  </ul>
</nav>

这是图像显示的方式:

在此处输入图像描述

我能做什么?

谢谢。

原文由 Lechucico 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 368
2 个回答

您可以使用 CSS 来对齐图像。

 <img width="130px" height="70px"src="{% static "series/images/logo.png"%}" style="position:relative;top:-10px">

原文由 Jhay 发布,翻译遵循 CC BY-SA 3.0 许可协议

你可以这样做——

工作示例

  .navbar-inverse .navbar-brand {
  display: flex;
  align-items: center;
  padding: 5px;
}
.navbar-brand img {
  height: 100%;
  margin-right: 20px;
}
 <html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
 <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
          <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
          <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
           <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
           <style type="text/css">

           </style>
           </head>
           <body>
            <nav class="navbar navbar-inverse navbar-fixed-top  ">
  <div class="navbar-header">
    <a class="navbar-brand" href="#">
      <img classs="img-responsive" width="130px" height="" src="https://cdn.pixabay.com/photo/2016/02/19/15/46/dog-1210559_960_720.jpg">
    </a>
    <a class="navbar-brand" href="">
      <span class="glyphicon glyphicon-home"></span> | MEGA SERIES  </a>
  </div>
  <ul class="nav navbar-nav">
    <li class="active"><a href="">Series</a></li>
  </ul>
</nav>
  </body>
  </html>

原文由 neophyte 发布,翻译遵循 CC BY-SA 3.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题