類似聊天輸入框右側固定「發送」按鈕,需將按鈕視覺上置於 <textarea> 或 <input> 內部右側。
.input-wrapper {
position: relative;
display: inline-block;
}
.input-wrapper textarea {
padding-right: 60px; /* 預留按鈕寬度 */
box-sizing: border-box;
}
.input-wrapper button {
position: absolute;
right: 5px;
top: 50%;
transform: translateY(-50%);
height: 30px;
width: 50px;
}
<div class="input-wrapper">
<textarea placeholder="輸入內容..."></textarea>
<button type="button">發送</button>
</div>

padding-right。z-index 確保按鈕在輸入框內容之上。