[英]How can I get a Material UI React Textfield to not be overlayed by text, when it has position sticky and it has been scrolled up?
Context:语境:
I have a little chat app with the chat in the middle, and a sticky textfield on the bottom.我有一个小聊天应用程序,中间是聊天,底部是粘性文本字段。 I want to have it when I scroll up the chatlist, that the Textfield will always be on the bottom but over the chat messages (so it has zIndex presedence).
我希望在向上滚动聊天列表时拥有它,文本字段将始终位于底部但在聊天消息上方(因此它具有 zIndex 存在)。
The Problem:问题:
But when I scroll now, the TextField
from react material ui, is behind the text, almost like it has a opacity or something.但是当我现在滚动时,来自 react material ui 的
TextField
位于文本后面,几乎就像它有不透明度或其他东西一样。
What have I tried:我尝试了什么:
I have set a high zIndex on the TextField
and also Elevation, but nothing changes the problem.我在
TextField
和 Elevation 上设置了很高的 zIndex,但没有任何改变。
Code snippet of the TextField: TextField 的代码片段:
<div
style={{
position: "sticky",
bottom: 5,
}}
>
<TextField
placeholder="Your Message.."
variant="outlined"
fullWidth
label="message"
color="primary"
value={message}
onChange={(e) => setMessage(e.target.value)}
onKeyDown={(e) => (e.keyCode === 13 ? submitMessage() : null)}
/>
</div>
Here is a screenshot how it looks currently:这是当前的屏幕截图:
just add background-color to the TextField...只需将背景颜色添加到 TextField ...
<TextField
placeholder="Your Message.."
variant="outlined"
fullWidth
label="message"
color="primary"
value={"aaaaaaaaaaa"}
onChange={(e) => setMessage(e.target.value)}
onKeyDown={(e) => (e.keyCode === 13 ? submitMessage() : null)}
style={{backgroundColor: "white"}}
/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.