如何在yii2中为链接添加自定义样式

时间:2015-09-05 14:07:51

标签: php yii2 yii2-advanced-app yii2-basic-app

使用管理员LTE并希望自定义侧边栏作为我的布局的一部分

Am customizing a link in yii2 by adding an extra style.
I have tried:
<li>
<?= Html::a('<span> Site </span>',['/site/index'],['class'=>'fa fa- calendar'],
  ['options'=>['template'=>'<small class="label pull-right bg-red">3</small>',
        ]]) ?>

    </li>

最终结果应为:

<li>
      <a href="pages/calendar.html">
            <i class="fa fa-calendar"></i> <span>Calendar</span>
            <small class="label pull-right bg-red">3</small>
          </a>
 </li>

问题是该部分:

small class="label pull-right bg-red">3</small>
does not get displayed

1 个答案:

答案 0 :(得分:1)

试试这种方式

<li>
 <?= Html::a('<span> Site </span><small class="label pull-right bg-red">3</small>',
    ['/site/index'],
    ['class'=>'fa fa- calendar'],
 ]) ?>
</li>