Html 将按钮附加到文本区域
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16929728/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Appending button to textarea
提问by John Smith
What I'm trying to do is append a button into a textarea's bottom right corner, like this:
我想要做的是在 textarea 的右下角附加一个按钮,如下所示:
However, I have no idea how I'd do this. Please help!
但是,我不知道该怎么做。请帮忙!
回答by Miro
You can use css to position the button there absolutely.
您可以使用 css 将按钮绝对定位在那里。
Here is a demo: http://jsfiddle.net/GwheP/
这是一个演示:http: //jsfiddle.net/GwheP/
div{
display:inline-block;
position:relative;
}
button{
position:absolute;
bottom:10px;
right:10px;
}
textarea{
display:block;
}
<div>
<textarea name="" id="txt" cols="20" rows="5"></textarea>
<button>Submit</button>
</div>
回答by WhyMe
Try the following,
尝试以下,
<div id='container' style='width:600px; border:1px solid black;'>
<textarea style='border-style:none none dashed none; border-color:black; width:100%; display:block;box-sizing:border-box;border-width:1px; margin-bottom:1px;'></textarea>
<div style='width:100%; box-sizing:border-box; height:35px;padding:5px;'>
<button style='float:right'>Lama mama
</button>
</div>
</div>
Also here.
也在这里。
回答by Rajender Joshi
HTML
HTML
<div class="wrapper">
<textarea name="somename" id="" cols="20" rows="10"></textarea>
<div class="controls">
<button>Post as Anonymous</button>
</div>
</div>
CSS
CSS
*{
padding: 0;
margin:0;
}
.wrapper{
background: #eee;
border: 1px solid #999;
width: 600px;
}
.wrapper textarea{
background: linear-gradient(to bottom, #e5e5e5 0%,#f2f2f2 100%);
border:none;
width:100%;
-moz-box-sizing: border-box;
box-sizing: border-box;
border-bottom: 1px dotted #999;
resize: none;
}
.wrapper textarea:focus{
outline: none;
}
.controls{
text-align: right;
margin-top: -6px;
}
button{
background: linear-gradient(to bottom, #ffffff 0%,#e5e5e5 100%);
border: 1px solid #999;
padding: 10px 25px;
font-weight: bold;
color: rgb(77,77,77);
border-width: 1px 0 0 1px;
}
回答by Yogesh K
I hope this css help you for button to fit in textarea on right corner... because of aligning the background position.....
我希望这个 css 可以帮助你让按钮适合右角的 textarea ......因为对齐背景位置......
textarea {
width: 100px;
height: 50px;
padding-right: 20px;
background-image: url('http://www.isilo.com/support/manual/iSiloIP/img/gearIcon.gif');
background-position: top right;
background-repeat: no-repeat;}