javascript - Is it possible to add a div to an element horizontally using javascript?
问题描述
I'm adding elements to a form in javscript using appendChild, and am wondering if there is a way to append horizontally instead of vertically? Using appendChild(), I tried this:
var select_fields = document.createElement('select');
select_fields.setAttribute('id', 'select_fields');
var select_operators = document.createElement('select');
select_operators.setAttribute('id', 'select_operators');
select_operators.setAttribute('display', 'inline')
var filter_field_header = document.createTextNode('Choose Field:');
filter.appendChild(filter_field_header);
filter.appendChild(select_fields);
filter.appendChild(select_operators);
But it still appends vertically. Is this possible?
解决方案
尝试使用 'float: left' 而不是使用 'display: inline'
推荐阅读
- laravel - 根据 Laravel 7 中的下拉值重新绘制视图
- visual-studio - 如何在 Visual Studio 安装程序 2015 中使用 now 安装程序覆盖服务器
- ios - 如何为动态键、json解析、swift5创建模型
- python - 在数据框中绘制数据时需要帮助
- excel - Excel 无法访问 ssas 多维数据集
- java - 用 spark 实现散列
- oauth-2.0 - 没有发现文档的 angular-oidc 库代码流
- xml - 如何使用 XSL 合并同一组的单元格?
- c++ - BOOST:ODEINT 突然迭代停止
- laravel - Laravel 存储权限为 774 的文件