将蚂蚁设计旋转木马在屏幕上
我调整了一个蚂蚁设计旋转木马的大小,想移动图像以出现在屏幕的中央。
这是我尝试的:
const contentStyle = {
height: '160px',
width: '25%',
color: '#fff',
lineHeight: '60%',
textAlign: 'center',
background: '#364d79',
justifyContent: 'center',
alignItems: 'center',
};
const imageStyle = {
flex: 1,
width: '100%',
height: '100%',
resizeMode: 'center',
}
return(
<>
<Carousel autoplay>
{
[onlineUsers].length === 0 ?
<p>There are currently no active users</p>
: onlineUsers.map(user => {
return (
<div className="img-container">
<h3 style={contentStyle}><img style={imageStyle} src={user.profile_pic} /></h3>
</div>
)
})
}
</Carousel>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在图像容器上使用
flex
。似乎在运行时,在容器上,display:inline-block
已分配。因此,我们必须使用显示:Flex!重要
才能使其工作。放置
width
&amp; amp;也很重要。高度:自动
到图像。CSS
JS
我制作了一个带有两个图像的沙箱,中央对齐。
You can use
flex
on the image container. It seems at runtime, on the container,display:inline-block
is assigned. So we have to usedisplay: flex !important
for it to work.It's also important to put a
width
&height:auto
to image.CSS
JS
I have made a sandbox with two images, different sizes, center aligned.
添加此CSS,应该可以正常工作
Add this CSS and it should work fine