制作带有内联按钮的表单
我有 2 个按钮和一个其中包含输入类型的表单。我希望它们全部都是内联的,但我做不到。
这就是我所拥有的:
.btn-registerLayout {
background-color: #425fab;
font-size: 10px;
outline: none;
text-align: left;
cursor: pointer;
height: 22px !important;
width: 50px !important;
padding: 0 !important;
margin: 0 !important;
}
.btn {
color: #fff !important;
}
/* Search Section*/
.header-search .header-search-box {
position: relative;
width: 100%;
}
.header-search-input {
width: 100%;
background: #f0f0f0;
font-size: 12px;
height: 20px;
transition: .2s;
color: darkgreen;
outline: none;
display: inline;
border: 1px solid red !important;
position: relative;
overflow: hidden;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="d-inline pl-5" style="float:left">
<div class="d-inline">
<form asp-action="Index" asp-controller="Products" class="form-inline" method="get">
<input type="search" class="header-search-input" name="SearchKey" placeholder="Search">
</form>
</div>
<button class="btn btn-registerLayout d-inline" style="width:28px !important">
<i class="ml-2 bi bi-person-plus-fill"></i>
</button>
<button class="btn btn-registerLayout d-inline">
<i class="ml-2 bi bi-box-arrow-in-right"></i><span style="padding-left:5px"> Login</span>
</button>
</div>
但我无法使表单与按钮内联,结果如下:
I have 2 buttons and a form with input type inside of it. I want all of them be inline , but I can't do that.
This is what I have:
.btn-registerLayout {
background-color: #425fab;
font-size: 10px;
outline: none;
text-align: left;
cursor: pointer;
height: 22px !important;
width: 50px !important;
padding: 0 !important;
margin: 0 !important;
}
.btn {
color: #fff !important;
}
/* Search Section*/
.header-search .header-search-box {
position: relative;
width: 100%;
}
.header-search-input {
width: 100%;
background: #f0f0f0;
font-size: 12px;
height: 20px;
transition: .2s;
color: darkgreen;
outline: none;
display: inline;
border: 1px solid red !important;
position: relative;
overflow: hidden;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="d-inline pl-5" style="float:left">
<div class="d-inline">
<form asp-action="Index" asp-controller="Products" class="form-inline" method="get">
<input type="search" class="header-search-input" name="SearchKey" placeholder="Search">
</form>
</div>
<button class="btn btn-registerLayout d-inline" style="width:28px !important">
<i class="ml-2 bi bi-person-plus-fill"></i>
</button>
<button class="btn btn-registerLayout d-inline">
<i class="ml-2 bi bi-box-arrow-in-right"></i><span style="padding-left:5px"> Login</span>
</button>
</div>
but I can not make form inline with buttons and result is like this:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在父级上添加 d-inline-flex 以使元素内联,然后您可以使用间隔符或 ml 来分隔输入中的按钮。
Add
d-inline-flex
on the parent to get the elements inline, then you can use spacers orml
to space out the buttons from the input.像某种包装器中的分组按钮总是效果更好一些。
Always works a bit better grouping buttons like that in a wrapper of some sort.