javascript - 如何使用 css flexbox 在文本输入中创建一个按钮?
问题描述
我正在尝试使用按钮创建一个简单的输入文本。但我想要输入框中的按钮。我正在使用 CSS 弹性框。
下面是代码
<style>
.container{
display: flex;
width: 500px;
justify-content: center;
align-items: center;
margin: 0 auto;
}
input{
height: 60px;
width: 320px;
background-color: #fce6ef;
border-radius: 50px;
border: 1px solid #ffc5dd;
}
button{
height: 54px;
width: 94px;
background-color: #ff0266;
color: #ffffff;
text-transform: uppercase;
border-style: none;
border-radius: 50px;
}
</style>
<body>
<div class="container">
<input type="text">
<button>Submit</button>
</div>
</body>
附上图片以便更好地理解:
解决方案
考虑以下(无position
):
.container {
display: flex;
width: 500px;
padding: 4px;
padding-left: 20px;
justify-content: center;
align-items: center;
margin: auto;
background-color: #fce6ef;
border-radius: 50px;
border: 1px solid #ffc5dd;
}
input {
width: 100%;
height: 54px;
background: none;
border: 0;
padding: 0;
outline: none;
}
button {
height: 54px;
width: 94px;
background-color: #ff0266;
color: #ffffff;
text-transform: uppercase;
border-style: none;
border-radius: 50px;
cursor: pointer;
outline: none;
}
<div class="container">
<input type="text">
<button>Submit</button>
</div>
推荐阅读
- c - 如何在没有函数调用和宏的情况下填充指针数组?
- javascript - 使用纯 JS 或 jQuery 从 JavaScript 中的 HTML 反序列化数据
- mongodb - 更新的 MongoDB Bulk 操作性能很慢
- elasticsearch - 使用标记器在弹性搜索中对文档进行分组
- xcode - 使用 bash 脚本展平导入语句
- c++ - 根据模板类型有条件地删除变量
- ubuntu - 如何从 ubuntu 服务器中删除 Jenkins
- android - 如何在保留 NavigationDrawer 的同时更改片段的同时更改 AppBarLayout?
- html - 网格瓷砖设计
- python - 股票数据下载python无库