将按钮添加到textarea

时间:2013-06-05 00:36:23

标签: html css twitter-bootstrap

我要做的是在textarea的右下角添加一个按钮,如下所示:

enter image description here

然而,我不知道我是怎么做到的。请帮忙!

4 个答案:

答案 0 :(得分:21)

您可以使用css绝对定位按钮。

以下是演示: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>

答案 1 :(得分:5)

Live Demo

HTML

<div class="wrapper">
    <textarea name="somename" id="" cols="20" rows="10"></textarea>
    <div class="controls">
        <button>Post as Anonymous</button>
    </div>
</div>

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;
}

答案 2 :(得分:4)

尝试以下方法,

<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>

here

答案 3 :(得分:0)

我希望这个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;}