【发布时间】:2014-05-21 00:17:48
【问题描述】:
小问题。我想将标签设置在输入框的左前方,以便它们在同一行内。
任何帮助都会很棒。
我的 HTML:
<div class="row">
<div class="col-12">
<label for="fname">First Name</label>
<input type="text" class="form-control input-lg" name="FNAME" id="FNAME">
</div>
</div>
<div class="row">
<div class="col-12">
<label for="lname">Last Name</label>
<input type="text" class="form-control input-lg" name="LNAME" id="LNAME">
</div>
</div>
Jquery 我试过了:
$('.row.col-12 label').each(function() {
$(this).insertBefore( $(this).next('input') );
});
表格的样子: enter link description here
一些 CSS:
form-group {
margin-bottom:15px;
}
.col-12 {
width:100%
}
.input-sm {
height: 30px;
padding: 5px 10px;
font-size: 12px;
line-height: 1.5;
border-radius: 3px;
}
select.input-sm {
height: 30px;
line-height: 30px;
}
textarea.input-sm {
height: auto;
}
.input-lg {
height: 45px;
padding: 10px 16px;
font-size: 18px;
line-height: 1.33;
border-radius: 6px;
}
select.input-lg {
height: 45px;
line-height: 45px;
}
textarea.input-lg {
height: auto;
}
【问题讨论】:
-
你可以使用 CSS 吗?
-
小提琴上面我只是复制和粘贴你的DOM,标签与文本框在同一行。这是你想要的还是???
-
哦,我希望,它们也附加了很多 CSS,所以目前标签位于输入框的顶部。
-
嗯...你也可以发布你的css吗?理想情况下,css 样式会影响您发布的 DOM 部分。
标签: javascript jquery html forms dom