【问题标题】:How to add TOOLTIP in Yii2 NavBar如何在 Yii2 NavBar 中添加 TOOLTIP
【发布时间】:2016-01-17 11:05:11
【问题描述】:

我已经尝试了很多人在网站、论坛上提出的建议。 (Activating Tooltip) 但我仍然没有成功。我在自己的布局文件中添加了这个编码。 视图/布局

导航栏小部件编码

 'items' => [  
            [
              'label' => '<span style="font-size:1.3em;" class="glyphicon glyphicon-cog"></span>', 
              'url' => ['/site/controlPanel'],
              'options' =>[ 
                              'data-toggle' => 'tooltip',  
                              'data-placement' => 'tooltip',
                              'title' =>'Control Panel', 
                              'class' => 'tooltipStyle'
                          ],
            ],
            [
              'label' => '<span style="font-size:1.3em;" class="glyphicon glyphicon-tasks"></span>', 
              'url' => ['/site/controlPanel'],
              'options' =>[ 
                              'data-toggle' => 'tooltip',  
                              'data-placement' => 'tooltip',
                              'title' =>'Day Summary',
                              'class' => 'tooltipStyle'
                          ],
            ],

CSS

.tooltipStyle + .tooltip > .tooltip-inner {
background-color: #000;
}
.tooltipStyle + .tooltip > .tooltip-arrow { 
    border-bottom-color:#ff0; 
}

最终我只想得到这样的输出

在对我的编码进行了一些修改之后,这个输出就会显示出来。

【问题讨论】:

    标签: twitter-bootstrap yii2 twitter-bootstrap-tooltip


    【解决方案1】:

    您可以通过这种方式将标题添加到标签中的标签...

    'items' => [  
            [
              'label' => '<span style="font-size:1.3em;" 
                       class="glyphicon glyphicon-cog"</span>'
                . '  Control Panel', 
              'options' =>[ 'data-toggle' => 'tooltip',  
                            'data-placement' => 'tooltip',
                             'title' =>'Notifications', 
                              'class' => 'myTooltipClass']
              'url' => ['/site/controlPanel'],
              'data-toggle' => 'tooltip',
              'title' => 'Control Panel',
            ],
    

    然后在你的 css 中添加这个类(例如:用于改变颜色)

    .myTooltipClass + .tooltip > .tooltip-inner {background-color: #ff0;}
    .myTooltipClass + .tooltip > .tooltip-arrow { border-bottom-color:#ff0; }
    

    【讨论】:

    • 我已经用过很多次了..我知道它正在工作..然后尝试删除数据切换和数据放置..
    • 我正在寻找如何使用引导程序的内置工具提示功能。运气不好还是不行
    • 谢谢!!。它现在正在工作。但我需要与图像中所示相同的样式。我该怎么做?
    • 嗯,这是另一个关于风格的问题,我认为你必须在 css 上工作,并尝试在 bootstrap 中查看一些示例..
    • 感谢您的回复。但你的答案并不完整。我只需要得到如图所示的确切样式。你知道怎么做吗?
    猜你喜欢
    • 2014-11-14
    • 2021-12-06
    • 2019-03-08
    • 2023-04-01
    • 1970-01-01
    • 2019-05-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多