引导位置绝对是文本区域中的链接

时间:2019-03-01 06:28:15

标签: javascript jquery html css css3

我在引导栏内有一些内容。我需要将链接放置在Textarea中,如下所示。

enter image description here

并且即使水平或垂直调整文本区域的大小,链接也应包含其位置。如何使用jquery或CSS实现此目标?

JS FIDDLE

<div class="row">
  <div class="col-sm-8">
    <a data-toggle="tooltip" data-placement="top" title="Record Feedback" role="button" class="recorded-feedback-modal">Link</a>    
    <textarea class="form-control" rows="4" spellcheck="false"></textarea>    
    <p>Test Content</p>
    <p>Test Content</p>
    <p>Test Content</p>
    </div>
</div>

CSS

.recorded-feedback-modal {
    position: absolute;
    bottom: 10px;
    right: 30px;
    z-index: 9999;
}

2 个答案:

答案 0 :(得分:2)

  • textarea周围创建一个相对容器,并链接为inline-block
  • 位置链接绝对在容器内部

enter image description here

.textarea-container {
  position: relative;
  display: inline-block;
}

.recorded-feedback-modal {
  position: absolute;
  bottom: 1em;
  right: 1em;
}
<div class="row">
  <div class="col-sm-8">
    <div class="textarea-container">
    <a data-toggle="tooltip" data-placement="top" title="Record Feedback" role="button" class="recorded-feedback-modal" href="#">Link</a>
    <textarea class="form-control" rows="4" spellcheck="false"></textarea>      
    </div>

    <p>Test Content</p>
    <p>Test Content</p>
    <p>Test Content</p>
  </div>
</div>

jsFiddle

答案 1 :(得分:0)

您能否添加一个新的div并将atextarea放入该div中。

.txtArea {
  position: relative
}
.recorded-feedback-modal {
    position: absolute;
    bottom: 10px;
    right: 30px;
    z-index: 1;
}
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="col-sm-8">


<div class="txtArea">
<a data-toggle="tooltip" data-placement="top" title="Record Feedback" role="button" class="recorded-feedback-modal">Link</a>
<textarea class="form-control" rows="4" spellcheck="false"></textarea>
</div>

<p>Test Content</p>
<p>Test Content</p>
<p>Test Content</p>
</div>
</div>