Yii CHtml::radioButtonList - 水平对齐的 CSS
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7128803/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Yii CHtml::radioButtonList - CSS to align horizontally
提问by Bujji
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 ?
我正在使用 yii 框架进行开发。我编写了 CSS 并且能够<input
正确地对齐html 中的标签,并且我对 yii 使用了相同的 CSS 并且对齐被搞砸了。有人可以帮我吗?
I wanted it to be displayed like below
我希望它显示如下
Here is the yii code I have
这是我的 yii 代码
<div id="gender">
<label>Gender :</label>
<?php echo CHtml::radioButtonList('gender_code','',array('Male'=>'Male','Female'=>'Female'),array('separator'=>'')); ?>
</div>
CSS
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
它如下图所示
回答by jamband
<?php echo CHtml::radioButtonList('gender_code','',array('Male'=>'Male','Female'=>'Female'),array(
'labelOptions'=>array('style'=>'display:inline'), // add this code
'separator'=>'',
)); ?>
回答by Joseph Marikle
Looks like you might need
看起来你可能需要
div#gender input
{
float:left;
}
回答by zuups
add this css code somewhere (to the end of css/main.css, for example):
将此 css 代码添加到某处(例如,到 css/main.css 的末尾):
input[type=radio] + label, input[type=checkbox] + label { display:inline !important; }