显然,我有一个很难的造型材料-ui组件,也许是我对框架的贫乏知识,但让我们判断,当我做完解释的情况。
我有一个登陆页面,显示一个视频作为背景,我想要的是添加其他组件到该视频屏幕的中心,如排印。
这是我的组成部分:
import React, {Fragment, useState} from 'react'
import {createStyles, Grid, makeStyles, Typography} from '@material-ui/core'
import DrawerC from '../components/drawer'
import AppbarC from '../components/appbar'
import background from '../assets/background.mp4'
const useBackgroundStyle = makeStyles((theme)=>createStyles({
root:{
width: '100%',
height: '100%',
overflowX: 'hidden'
},
typographyMiddle:{
∎∎∎∎∎∎ SOME STYLING TO POSITION THE TYPOGRAPHY IN THE MIDDLE ∎∎∎∎∎∎
position: 'absolute',
∎∎∎∎∎∎ ------------------------------------- ∎∎∎∎∎∎
},
[theme.breakpoints.down('md')]:{
root:{
width: window.screen.width,
height: window.screen.height,
objectFit: 'cover',
objectPosition: '20% 0%',
overflowX: 'hidden'
}
}
}))
export default function () {
const backgroundStyle = useBackgroundStyle()
const [drawerState, handleDrawerState] = useState(false)
const [datepickerState, handleDatepicker] = useState(false)
return(
<Fragment>
<AppbarC handleDrawerState={handleDrawerState} handleDatepicker={handleDatepicker} />
∎∎∎∎∎∎ THIS IS THE PART OF THE CODE THAT MATTERS ∎∎∎∎∎∎
<video autoPlay='autoplay' muted loop id="myVideo" className={backgroundStyle.root}>
<source src={background} type="video/mp4" />
</video>
<Grid
container
spacing={0}
direction="column"
alignItems="center"
justify="center"
style={{ minHeight: '100vh' }}
className={backgroundStyle.typographyMiddle}
>
<Typography className={backgroundStyle.typographyMiddle}> THIS IS A TEST </Typography>
</Grid>
∎∎∎∎∎∎ ------------------------------------- ∎∎∎∎∎∎
<DrawerC state={drawerState} handleDrawerState={handleDrawerState} />
</Fragment>
)
}我尝试了这个方法,这是我在另一个stackoverflow question asked by someone else中看到的,但它所做的只是对排版进行居中,但它为页面增加了额外的空白。
因此,我想知道的主要问题是:
什么是集中不是framework?
发布于 2020-08-27 15:39:42
您应该能够在父(包装)组件上使用“位置:相对”,然后在子组件上使用“位置:绝对”,并且使用%+ vh,您可以将子组件放置在父组件的任何位置。
https://stackoverflow.com/questions/63605849
复制相似问题