Yii CHtml::radioButtonList - CSS to align horizont

2019-02-22 10:48发布

I am using yii framework for my development . I wrote CSS and able to align my <input tags in html properly and I am using the same CSS for yii and the alignment is messed up . Could some help me on this ?

I wanted it to be displayed like below

I wanted it to be displayed like below

Here is the yii code I have

<div id="gender">
        <label>Gender :</label>
        <?php echo CHtml::radioButtonList('gender_code','',array('Male'=>'Male','Female'=>'Female'),array('separator'=>'')); ?>
    </div>

CSS

 <style type="text/css">          
           div#gender {
                    margin-top:20px;
                    margin-left:200px;
           }      

           div#gender label
           {
                   font-weight: bold;
                   font-size: 0.9em;
                   float:left;
                   margin-left:2px;
                   text-align:left;
                   width:100px;
            }

</style>

and it is coming as below image

enter image description here

3条回答
放我归山
2楼-- · 2019-02-22 11:25

Looks like you might need

div#gender input
{
    float:left;
}
查看更多
劳资没心,怎么记你
3楼-- · 2019-02-22 11:27

add this css code somewhere (to the end of css/main.css, for example):

input[type=radio] + label, input[type=checkbox] + label { display:inline !important; }
查看更多
放荡不羁爱自由
4楼-- · 2019-02-22 11:29
<?php echo CHtml::radioButtonList('gender_code','',array('Male'=>'Male','Female'=>'Female'),array(
    'labelOptions'=>array('style'=>'display:inline'), // add this code
    'separator'=>'',
)); ?>
查看更多
登录 后发表回答