Chakra-UI 文本组件 noOfLines 在 Safari 中无法正确显示
我在Next.js打字网络应用程序中拥有脉轮-UI文本组件。 Nooflines在Safari中不正确显示,但在Chrome中正确。有什么建议吗?
<Box pt={3} width={'100%'}>
<Text noOfLines={show ? 0 : 2}>
<ReactMarkdown>{collection.description}</ReactMarkdown>
</Text>
<Button size="sm" onClick={handleToggle} variant={"link"}>
Show {show ? "Less" : "More"}
</Button>
</Box>
I havea a Chakra-UI Text component in a Next.js TypeScript web app. The noOfLines doesn't display right in Safari, but correct in Chrome. Any suggestions?
<Box pt={3} width={'100%'}>
<Text noOfLines={show ? 0 : 2}>
<ReactMarkdown>{collection.description}</ReactMarkdown>
</Text>
<Button size="sm" onClick={handleToggle} variant={"link"}>
Show {show ? "Less" : "More"}
</Button>
</Box>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我有
nooflines
与reactmarkdown
完全相同的堆栈和问题。我通过nooflines
与maxheight
:注意:注意:您将失去省略号和
witchoverflow ='Ellipsis'
不适用于我。I have the exact same stack and problem with
noOfLines
not playing nicely withReactMarkdown
. I worked around this by swappingnoOfLines
withmaxHeight
:Note: You'll lose the ellipsis and
textOverflow='ellipsis'
wasn't working for me.我遇到了同样的问题,我通过使用
Overflow
和maxheight
属性来解决它:Safari:I had the same problem, I solved it with using
overflow
andmaxHeight
properties for Safari :这是一个简单的情况,您很可能甚至不需要脉轮。您需要在截断字符串本身上设置宽度/高度。参见 https://css-tricks.coms.com/snippets/snippets/css/css/css/css/css/ truncate-string-with-ellipsis/
This is a simple case where you most likely don't even need Chakra. You need to set a width/height on the string itself before it can be truncated. See https://css-tricks.com/snippets/css/truncate-string-with-ellipsis/