gpt4 book ai didi

Yii2 如何将类添加到菜单项的标签

转载 作者:行者123 更新时间:2023-12-04 13:05:13 25 4
gpt4 key购买 nike

如何在标签(项目)上添加 CSS 类

示例:
['label'=>'Home', 'url'=>['site/home']]
这不起作用
['label'=>'Home', 'class'=>'list-group-item', 'url'=>['site/index']],

最佳答案

刚刚开源的 Nav 小部件:

/**
* @var array list of items in the nav widget. Each array element represents a single
* menu item which can be either a string or an array with the following structure:
*
* - label: string, required, the nav item label.
* - url: optional, the item's URL. Defaults to "#".
* - visible: boolean, optional, whether this menu item is visible. Defaults to true.
* - linkOptions: array, optional, the HTML attributes of the item's link.
* - options: array, optional, the HTML attributes of the item container (LI).
* - active: boolean, optional, whether the item should be on active state or not.
* - items: array|string, optional, the configuration array for creating a [[Dropdown]] widget,
* or a string representing the dropdown menu. Note that Bootstrap does not support sub-dropdown menus.
**/

所以如果你想为 li 项目添加类,请使用
['label'=>'Home', 'url'=>['site/index'],'options'=>['class'=>'list-group-item']]

如果你想添加类链接
[
'label'=>'Home',
'url'=>['site/index'],
'options'=> ['class'=>'list-group-item'],
'linkOptions'=>['class'=>'item-a-class'],
]

关于Yii2 如何将类添加到菜单项的标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25832160/

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