【问题标题】:Button inside the textarea overlaps text文本区域内的按钮与文本重叠
【发布时间】:2020-11-06 23:36:09
【问题描述】:

我在这里遇到了文本与 Emoji 按钮重叠的问题。 基本上我希望文本在到达表情符号之前停止。 我试过这个,出人意料地对我不起作用http://jsfiddle.net/36bw0nmo/14/

谢谢

这是我的小提琴https://jsfiddle.net/w0s4y5nk/14/

textarea#sendMessage {
    height:50px;
    width: calc(100vw - 15px);
    position: absolute;
    bottom: 16px;
    resize: none;
    border: none;
    font-size: 13px;
    padding: 5px 5px 5px 10px;
    border: solid 5px
}

#myButton {
      position: absolute;
      bottom: 10px;
      right: 5px;      
      margin-left: 60px;

    }
    
    
  <textarea id="sendMessage"> </textarea>
  <p id="myButton" role="img" onclick='$("#picker").toggle()'>&#x1F642</p>
  <emoji-picker id="picker"> </emoji-picker>

【问题讨论】:

  • 您的 sn-p 工作正常,您提供的 fiddle 代码不同,请更新问题
  • @dippas 看最后一行,这里jsfiddle.net/w0s4y5nk/14 确保控制台最小化

标签: html css margin margin-left


【解决方案1】:

我希望这是你想要的

.textarea-container {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  height: 50px;
  max-width: 96%;
  width: 96%;
  margin: 0 auto;
  position: absolute;
  box-sizing: content-box;
  bottom: 16px;
  padding: 6px;
  border: solid 1px #ccc;
  border-radius: 4px;
}

textarea#sendMessage {
    max-width: 100%;
    width: 100%;
    height: 100%;
    resize: none;
    border: none;
    font-size: 13px;
    scrollbar-width: none; 
    -ms-overflow-style: none; 
}

textarea#sendMessage::-webkit-scrollbar { 
    display: none;
}

textarea:focus {
    outline: none !important;
}

#myButton {
  width: 24px;
  height: 24px;
  display: inline;
  cursor: pointer;
  padding-left: 4px;
  margin: 0;
}
<div class="textarea-container">
  <textarea id="sendMessage"> </textarea>
  <p id="myButton" role="img" onclick='$("#picker").toggle()'>&#x1F642</p>
  <emoji-picker id="picker"> </emoji-picker>
</div>

运行 sn-p 代码并查看结果。

【讨论】:

  • 是的!但是每个人都知道我们作弊了,因为在插入第三行之后,滚动显示在表情符号和文本区域之间。除了 99% 的完美之外。
  • @BitcoinKing 现在试试,我隐藏了滚动条
  • 完美,谢谢!现在表情符号按钮似乎是固定的,我希望它像原始帖子一样位于底部。任何想法? @Ramin eghbalian
  • @BitcoinKing 好的,我把它移到底部
  • 你已经超出了我的预期!谢谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-10-30
  • 1970-01-01
  • 2018-09-07
  • 1970-01-01
  • 2016-08-25
  • 1970-01-01
  • 2018-12-29
相关资源
最近更新 更多