简体   繁体   中英

yii, How To Change The Text Color On A Cmenu

im trying to find where is the class css that contains the color of this text..

the text if in the menu that gii generates by default on right next to the CListView.. the color is blue but i would like to change it to white for my custom theme, so where can i find this and please tell me if i can set its setting just for this action, i posted the same question on yii forum here , but noone answers.

please help.

Just add into the selector a class and you can make style for it. I'm not sure what you were trying to do, just look at following example

Setup

$this->widget('zii.widgets.CMenu', array(
    'items'=>array(
        array('label'=>'Home', 'url'=>array('site/index'),'linkOptions' => array('class'=>'anchor-link')),
        array('label'=>'Products', 'url'=>array('product/index'), 'items'=>array(
            array('label'=>'New Arrivals', 'url'=>array('product/new', 'tag'=>'new'),'linkOptions' => array('class'=>'anchor-link')),
            array('label'=>'Most Popular', 'url'=>array('product/index', 'tag'=>'popular'),'linkOptions' => array('class'=>'anchor-link')),
        )),
    ),
    'htmlOptions' => array('class'=>'menu-container-class'),
    'activeCssClass' => 'active-class',
    'itemCssClass' => 'item-class',
    'submenuHtmlOptions' => array('class'=>'sub-menu-class')
));

Result

<ul id="yw0" class="menu-container-class">
    <li class="item-class"><a href="/khucholon/site/index.html" class="anchor-link">Home</a></li>
    <li class="item-class"><a href="/khucholon/product/index.html">Products</a>
        <ul class="sub-menu-class">
            <li class="item-class"><a href="/khucholon/product/new.html?tag=new">New Arrivals</a></li>
            <li class="item-class"><a href="/khucholon/product/index.html?tag=popular">Most Popular</a></li>
        </ul>
    </li>
    <li class="item-class"><a href="/khucholon/site/login.html">Login</a></li>
</ul>

CSS

.item-class a{color:red}

or you can use and custom yourself with some of the pseudo-classes

a.anchor-link:link, a.anchor-link:active, a.anchor-link:hover, a.anchor-link:visited{
color:red
}

Almost you can set css for the node level what you want by using following options:

linkOptions (for inmost link)

htmlOptions , activeCssClass , itemCssClass , submenuHtmlOptions , firstItemCssClass

See more Yii CMenu

Try setting your own class to the menu with htmlOptions and use that css class to style as per your need.

$this->widget('zii.widgets.CMenu', array(
    'htmlOptions' => array('class' => 'mynav'),

And in your css

.mynav{
color:red
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM