【发布时间】:2020-07-08 15:26:07
【问题描述】:
我有一个 field_wrapper 类 div,其中包含 3 个子 div field_label、field_input 和 field_error
我需要将 field_label、field_input 和 field_error 并排放在前两者的下方。
请参阅下面的 css 代码以了解我是如何实现的,我的问题是它在 IE7 中不起作用。清除两者都应用于 field_error 不起作用。
即使在谷歌上搜索了很长时间后,如果不添加 HTML 标记,我也找不到合适的方法来解决这个问题。请建议 css 提示或任何其他方法以避免额外的标记代码
.field_wrapper
{
clear:both;
}
.field_label
{
float:left;
width:40%;
}
.field_input
{
float:left;
width:40%;
}
.field_error
{
clear: both;
color:#FF0000;
float: right;
text-align:left;
width: 60%;
}
<form method="post" action="http://localhost/locations/add">
<div class="field_wrapper">
<div class="field_label">
<label for="location_add_name">Name</label>
</div>
<div class="field_input">
<input type="text" id="location_add_name" value="" name="name">
</div>
<div class="field_error">
<p>The Name field is required.</p>
</div>
</div>
<div class="field_wrapper">
<div class="field_label">
Address
</div>
<div class="field_input">
<textarea id="location_add_address" rows="12" cols="90" name="address"></textarea>
</div>
<div class="field_error">
</div>
</div>
<div class="form_submit">
<input type="submit" value="Add" name="submit">
</div>
</form>
【问题讨论】:
标签: css css-float internet-explorer-7