如何解决html表单输入文本并在同一行上提交
我创建一个表格。那样,我需要在同一行上添加文本框和提交按钮。
<div class="input-group">
<form action="searchresult.php" method="post">
<input type="text" name= "searchtext" class="form-control" placeholder="Search">
<button class="btn btn-secondary" type="submit">
<svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-search" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" d="M10.442 10.442a1 1 0 0 1 1.415 0l3.85 3.85a1 1 0 0 1-1.414
1.415l-3.85-3.85a1 1 0 0 1 0-1.415z"/>
<path fill-rule="evenodd" d="M6.5 12a5.5 5.5 0 1 0 0-11 5.5 5.5 0 0 0 0 11zM13 6.5a6.5
6.5 0 1 1-13 0 6.5 6.5 0 0 1 13 0z"/>
</svg>
</button>
</form>
</div>
解决方法
好像您正在使用引导程序。
将两个元素包装在row
中,并使用column
结构。必要时调整填充/边距。有关更多信息,请查看网格系统上的引导程序文档:https://getbootstrap.com/docs/4.0/layout/grid/
<div class="input-group">
<form action="searchresult.php" method="post">
<div class="row>
<div class="col-lg-6">
<input type="text" name= "searchtext" class="form-control" placeholder="Search">
</div>
<div class="col-lg-6">
` <button class="btn btn-secondary" type="submit">
<svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-search" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" d="M10.442 10.442a1 1 0 0 1 1.415 0l3.85 3.85a1 1 0 0 1-1.414
1.415l-3.85-3.85a1 1 0 0 1 0-1.415z"/>
<path fill-rule="evenodd" d="M6.5 12a5.5 5.5 0 1 0 0-11 5.5 5.5 0 0 0 0 11zM13 6.5a6.5
6.5 0 1 1-13 0 6.5 6.5 0 0 1 13 0z"/>
</svg>
</button> `
</div>
</div>
</form>
</div>
这些列最多需要加12,因此您可以根据需要进行更改。
col-lg-4
作为输入
col-lg-8
(用于按钮)
或其他您想做的。如果您需要进一步调整间距,我认为在Bootstrap 4中有一个用于控制元素填充的类:
https://getbootstrap.com/docs/4.4/utilities/spacing/
例如,您可以将类p-0
添加到按钮中,这将消除元素上的填充
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。