我能够显示我想要的数据,并且我的对齐方式很接近。但我现在面临着一个问题
我的问题是我的顶级帖子数据没有显示滚动条
我以为添加min-w-0 max-h-full overflow-y-scroll
就能解决这个问题。目前,默认的20帖子会拉伸我的容器,而不是使其可滚动
下面是我的代码样例中的codesanbox链接。任何解释都值得感谢。
附注:我使用顺风。
<div className="min-w-0 max-h-full overflow-y-scroll">
<ContentHeader title="Top Post" /> {posts.map(post => (
<div key={post.id}>
<div className='px-10 my-4 py-4 bg-white border border-8 border-gray-400 rounded-lg border-solid'>
<div className='flex justify-between'>
<span className='font-light text-black text-lg font-semibold'>@{post.username}</span>
<span className='font-medium rounded ml-56'> {moment(post.postDate).format(('L'))}. {moment(post.postDate).format(('LT'))}</span>
<a className="font-extrabold rounded text-3xl text-blue-600" href={post.postUrl} target="_blank" rel="noopener noreferrer">
<BsArrowUpRight />
</a>
</div>
<div className="mt-2">
<p className='mt-2 text-xl text-gray-600'>{post.textContent}</p>
</div>
<SocialAction likeCount={post.likeCount} commentCount={post.commentCount} sentiment={post.sentiment} />
</div>
</div>
))}
</div>
这是它使用滚动条时的外观:
发布于 2020-06-04 13:34:16
我相信您希望使用max-h-screen
而不是max-h-full
。max-h-full
给出了元素height: 100%
,在本例中,它什么也不做。max-h-screen
给了height: 100vh
,所以它实际上是在变高。
https://codesandbox.io/s/stackoverflow-62186352-lwj1n?file=/src/Toppost.js
在本例中,我添加了before
和after
文本,以便您可以看到滚动条。
https://stackoverflow.com/questions/62186352
复制相似问题