【发布时间】:2016-12-10 17:04:09
【问题描述】:
如何在 "row" 中对齐超过 2 个相同大小的元素,我使用 "+" 动态创建行,当我输入 "display: inline-flex; width: 100%" 时其他行都可以,但是如果“第一行”是 inline-flex 它会坏掉,当我点击更多行时,它不会下降,它会使它们在同一行 :
<select class=" col-sm-5">
<option> - Select Component - </option>
</select>
<input class="col-sm-2 col-sm-offset-2" type="text" name="mytext[]">
<div class="btn btn-default col-sm-1 col-sm-offset-2 add_field_button"><span class="glyphicon glyphicon-plus"></span></div>
jQuery
$(document).ready(function () {
var max_fields = 5; //maximum input boxes allowed
var wrapper = $(".input_fields_wrap"); //Fields wrapper
var add_button = $(".add_field_button"); //Add button ID
var x = 1; //initlal text box count
console.log(add_button);
add_button.click(function (e) { //on add input button click
e.preventDefault();
if (x < max_fields) { //max input box allowed
x++; //text box increment
wrapper.append('<div style="display: inline-flex; width: 100%; " class="input_fields_wrap">\
<select class=" col-md-5">\
<option> - Select Component - </option>\
</select>\
<input class=" col-md-2 col-md-offset-2" type="text" name="mytext[]">\
<button class="btn btn-default col-md-1 col-md-offset-2 remove_field"><span class="glyphicon glyphicon-trash"></span></button>\
</div>'
);
}
});
wrapper.on("click", ".remove_field", function (e) { //user click on remove glyphicon
e.preventDefault();
$(this).parent('div').remove();
x--;
});
});
【问题讨论】:
标签: html css twitter-bootstrap yii2 alignment