给 NavBar 添加 Logo 和标题 (Yii2)

Add Logo & Title to NavBar (Yii2)

如何向 Yii2 网络应用程序添加徽标和标题?

我使用连接将徽标贴在标题上(如下所示)

 NavBar::begin([
    'brandLabel' => '<img src="favicon-32x32.png"; class="img-responsive">'.'Car Management System',

它起作用了,但徽标出现在标题的顶部。 这是错误的制作方法吗? 或者是正确的但它需要更改一些样式属性?

看看这是否适合您,它只是将 <img> 语法更改为正确的:

'brandLabel' => '<img src="favicon-32x32.png" class="img-responsive"/>Car Management System',

如果您遇到图像和文本不在同一行的问题,您可能需要将 img-responsive class 替换为 pull-left class... 或者只是删除 img-responsive class 它可能会开始工作(取决于已经应用于图像的样式)。示例:

'brandLabel' => '<img src="favicon-32x32.png" class="pull-left"/>Car Management System',

我也有同样的问题,另外我还有一个正方形的图片48x48。我已经像您的初始解决方案一样解决了它,但借助于以下 style 属性的值:

...
'brandLabel' => '<img src="logo.png" style="display:inline; vertical-align: top; height:32px;">My Company',
...

最终结果如下图所示: