[英]How to add a button inside a input field
I have created a input field and a button but i want to put that button insiade that input field.我创建了一个输入字段和一个按钮,但我想将该按钮放在该输入字段中。 I have done it by using
position:absolute
but the problem is its not working properly in medium or large screen.我已经通过使用
position:absolute
完成了它,但问题是它在中或大屏幕中无法正常工作。 Any kind of help would be highly appreciated.任何形式的帮助将不胜感激。 Here is my code
这是我的代码
HTML CODE代码
<div>
<div style="float: left;width: 82%">
<input type="text" class="sent-message-text">
<img src="../img/camera.png" class="post-image-uploaad">
</div>
<div style="float: right">
<button class="no-button-design"><img src="../img/msg-sent.png" class="post-image-uploaad" style="margin-right: 15px;"></button>
</div>
</div>
</div>
CSS CODE CSS 代码
.fixed-bottom2 {
box-shadow: inset 0px 4px 5px #ededed;
padding: 9px;
margin:-20px !important
}
.sent-message-text {
border: 1px solid;
margin: 10px 0px 10px 15px;
min-height: 36px;
border: 1px solid #1486ab66 !important;
border-radius: 4px;
width: 92%;
}
.post-image-uploaad {
width: auto;
height: 22px;
margin-top: 8px;
}
.no-button-design {
padding: 0px;
border: 0px;
background-color: transparent;
margin: 0px;
}
.no-button-design img {
height: 34px;
}
In small screen its perfectly fine在小屏幕上它非常好
But in large screen it's coming out from the input field但在大屏幕上,它是从输入字段中出来的
use this code 使用此代码
css:- CSS: -
.fixed-bottom2 {
box-shadow: inset 0px 4px 5px #ededed;
padding: 9px;
margin: -20px !important
}
.sent-message-text {
border: 1px solid;
margin: 10px 0px 10px 15px;
min-height: 36px;
border-radius: 4px;
width: 100%;
position: relative;
}
.post-image-uploaad {
position: relative;
width: auto;
height: 22px;
margin: -39px -3px 1px 1px;
float: right;
}
.no-button-design {
padding: 0px;
border: 0px;
background-color: transparent;
margin: 19px 35px;
}
.no-button-design img {
height: 34px;
}
html:- HTML: -
<div>
<div style="float: left;width: 82%">
<input type="text" class="sent-message-text">
<img src="../img/camera.png" class="post-image-uploaad">
</div>
<div>
<button class="no-button-design"><img src="../img/msg-sent.png" class="post-image-uploaad_send" style="margin-right: 15px;"></button>
</div>
</div>
</div>
form { display: inline-block; position: relative; } form button { position: absolute; top: 0; right: 0; }
<!DOCTYPE html> <html> <body> <form action="/action_page.php"> <input name="search" type="text"> <button type="submit">click</button> </form> </body> </html>
try this good luck 试试这个好运
Try This: 尝试这个:
<!DOCTYPE html> <html> <head> <title>Hello</title> </head> <body> <input type="text"/><button class="btn">button</button> </body> </html>
.search { margin-bottom: 30px; } form { display: flex; flex-direction: row; justify-content: flex-end; align-items: center; } input { position: relative; width: 280px; height: 30px; } button { position: absolute; margin-right: 3px; padding: 8px 10px; background-color: #e7c130; border: none; }
<div className='search'> <form> <input type='text' /> <button>SEARCH</button> </form> </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.