Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
List Can';t清除水平列表后的浮动_List_Forms_Radio Button_Css Float - Fatal编程技术网

List Can';t清除水平列表后的浮动

List Can';t清除水平列表后的浮动,list,forms,radio-button,css-float,List,Forms,Radio Button,Css Float,我正在创建一个表单,并使用float水平显示一组单选按钮以节省空间。然而,之后我无法清除浮标,收音机下面的标题就在它们旁边 html代码如下所示: <div class="choice"> <ul> <li><label for="yes">Yes</label><input type="radio" name="newsletter" id="yes" value="yes"/></li> <li&g

我正在创建一个表单,并使用float水平显示一组单选按钮以节省空间。然而,之后我无法清除浮标,收音机下面的标题就在它们旁边

html代码如下所示:

<div class="choice">

<ul>

<li><label for="yes">Yes</label><input type="radio" name="newsletter" id="yes" value="yes"/></li>
<li><label for="no">No</label><input type="radio" name="newsletter" id="no" value="no"/></li>

</ul>

</div>

<h2>Questions or Comments</h2>
.choice ul li label {width: 30px;}

.choice ul li {float:left;}

.choice {clear:both;}
输出如下所示(此处用星号表示单选按钮):

我试着用左边的一个无障碍物做选择。 更改了
。选择
样式,如下面所示

CSS:

.choice:after {content:"#"; visibility:hidden; clear:both;}
这对你有用吗

h2 {clear:both;}

尝试了上述方法,似乎效果不错。

您使用了此样式代码

.choice ul li {clear:both}

这是清晰的代码

HTML:


欢呼………

你想在下一行显示h2内容吗?是的,我希望它在下一行。在firefox和opera中看起来不错,但在IE(我使用IE 9)中,h2仍然与单选按钮在同一行。另一个是将celar:left应用于h2标记。
.choice ul li {clear:both}
<div class="choice">

<ul>

<li><label for="yes">Yes</label><input type="radio" name="newsletter" id="yes" value="yes"/></li>
<li><label for="no">No</label><input type="radio" name="newsletter" id="no" value="no"/></li>

</ul>
    <div class="clear"></div>
</div>

<h2>Questions or Comments</h2>
.choice ul li label {width: 30px;}

.choice ul li {float:left;}

.clear {clear:both;}