第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何制作可擴展的聊天輸入表單

如何制作可擴展的聊天輸入表單

哆啦的時光機 2021-05-13 14:15:34
我一直在尋找一種方法來像在現(xiàn)代聊天應用程序中一樣垂直擴展文本輸入表單。每個人都說我們應該使用textarea,因為表單輸入不允許多行,但是松弛和頻譜正在使用表單...(但不協(xié)調(diào)時使用text-area)我想從一行開始,當用戶輸入換行符(Shift + Enter)時,輸入將擴展到頂部。.chat-footer {  display: grid;  grid-template-rows: 90vh max-content;  height: 100%;  background-color: var(--color-i-bg);  grid-area: i;  border-top: 1px solid #ddd;  border-top: var(--color-i-border-top);  padding-bottom: 1rem;}.chat-footer__form {  align-self: end;  display: grid;  grid-row: 2 / 3;  grid-template-columns: 1fr max-content;  width: 100%;  height: 100%;  vertical-align: middle;  white-space: normal;  background: none;  line-height: 1;}.chat-footer__form::placeholder {  color: lightgrey;  font-size: 1em;}.chat-footer__form-container-input {  grid-column: 1/2;}.chat-footer__form-container-btn {  grid-column: 2/3;}.chat-footer__form-input {  width: 100%;  height: 100%;}.chat-footer__form * > button {  background-color: inherit;  border: 0;  line-height: normal;}.chat-footer__form * > button:hover {  cursor: pointer;}.chat-footer__form * > button:focus, .chat-footer__form * > button:active {  outline: 0;} <div class="chat-footer">        <form class="chat-footer__form" role="form">            <div class="chat-footer__form-container-input">                <input type="text" class="chat-footer__form-input" placeholder="New message">            </div>            <div class="chat-footer__form-container-btn">                <button class="chat-footer__form-btn" id="form-attach">Attach</button>                <button class="chat-footer__form-btn" id="form-smiley">Smiley</button>            </div>        </form>    </div>我不反對使用文本區(qū)域,如果它是一個更好的解決方案。
查看完整描述

2 回答

?
狐的傳說

TA貢獻1804條經(jīng)驗 獲得超3個贊

您可以有一個div(無輸入,無文本區(qū)域)并使用contenteditable="true"屬性:

<div contenteditable="true"></div>

現(xiàn)在,當用戶單擊div時,他們可以編寫東西!就像輸入一樣。因此,您只需要偵聽此div的事件,例如,當用戶按下時shift+enter添加<br>標簽或創(chuàng)建一些段落。

我檢查了松弛輸入,他們使用了相同的技術。您可能還需要使用其他一些屬性:

 autocomplete="off" autocorrect="off" spellcheck="true" aria-expanded="false" aria-autocomplete="list" aria-multiline="true" aria-label="Message" dir="auto" contenteditable="true" role="textbox"


查看完整回答
反對 回復 2021-05-27
  • 2 回答
  • 0 關注
  • 137 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號