gpt4 book ai didi

css - 如何在 Yii2 中自定义 Navbar 属性

转载 作者:技术小花猫 更新时间:2023-10-29 11:21:30 24 4
gpt4 key购买 nike

我有这样的导航标题:

<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container-fluid">
<div class="navbar-collapse collapse">
<form class="navbar-form navbar-right" role="search">
<div class="form-group has-feedback">
<input id="searchbox" type="text" placeholder="Search" class="form-control">
<span id="searchicon" class="fa fa-search form-control-feedback"></span>
</div>
</form>
</div><!--/.navbar-collapse -->
</div>
</div>

当我想使用 yii\bootstrap\NavBar; 转换此代码时遇到问题:

<div class="navbar-collapse collapse">
<form class="navbar-form navbar-right" role="search">
<div class="form-group has-feedback">
<input id="searchbox" type="text" placeholder="Search" class="form-control">
<span id="searchicon" class="fa fa-search form-control-feedback"></span>
</div>
</form>
</div><!--/.navbar-collapse -->

这是我使用 yii\bootstrap\NavBar;Layout 代码:

<?php
NavBar::begin([
'brandLabel' => 'My Company',
'brandUrl' => Yii::$app->homeUrl,
'options' => [
'class' => 'navbar navbar-inverse navbar-fixed-top',
'role' => 'navigation',
],
]);
NavBar::end();
?>

我已阅读Navbar Widget ,还是不明白。有没有人可以教我在 Yii2 框架 上使用 Navbar 小部件?

最佳答案

好的,这里是代码,我只是根据你发布的问题放置 searchbox,我猜你知道如何 echo other导航栏中的菜单链接

总之就是这样

<?php
NavBar::begin([
'brandLabel' => 'My Company',
'brandUrl' => Yii::$app->homeUrl,
'options' => [
'class' => 'navbar navbar-inverse navbar-fixed-top',
'role' => 'navigation',
],
]);

$menuItems = [
['label' => 'Home', 'url' => ['controller url here']],
];

echo Nav::widget([
'options' => ['class' => 'navbar-nav navbar-right'],
'items' => $menuItems,
]);
echo "<form class='navbar-form navbar-right' role='search'>
<div class='form-group has-feedback'>
<input id='searchbox' type='text' placeholder='Search' class='form-control'>
<span id='searchicon' class='fa fa-search form-control-feedback'></span>
</div>
</form>";
NavBar::end();
?>

关于css - 如何在 Yii2 中自定义 Navbar 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33369686/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com