javascript - 如何在中间定位行反应语义ui
问题描述
我将如何使用反应语义 ui 网格行将行定位在中间?想知道除了增加 padding-top 直到它到达中间是否还有其他方法
<Container>
<Grid columns={4} divided>
<Grid.Row>TITLE</Grid.Row>
<Grid.Row>
<Grid.Column width={4} color="violet" textAlign="center">
<h3>Content</h3>
</Grid.Column>
<Grid.Column textAlign="center" width={4} color="violet">
<h3>Content</h3>
</Grid.Column>
<Grid.Column textAlign="center" width={4} color="violet">
<h3>Content</h3>
</Grid.Column>
<Grid.Column textAlign="center" width={4} color="violet">
<h3>Content</h3>
</Grid.Column>
</Grid.Row>
</Grid>
</Container>
解决方案
您可以使用verticalAlign 道具middle
并为Grid.Row
解决您的问题提供一个值。还要确保为网格提供高度。
根据文档:
- 网格可以指定其垂直对齐方式以使其所有列垂直居中。</li>
- 行可以指定其垂直对齐方式,使其所有列垂直居中。
<Container style={{ height: "100vh", background: "lightblue" }}>
<Grid
style={{ height: "400px", background: "gray" }}
columns={4}
divided
padded={false}
>
<Grid.Row verticalAlign="middle">
<Grid.Column width={4} color="violet" textAlign="center">
<h3>Content</h3>
</Grid.Column>
<Grid.Column textAlign="center" width={4} color="violet">
<h3>Content</h3>
</Grid.Column>
<Grid.Column textAlign="center" width={4} color="violet">
<h3>Content</h3>
</Grid.Column>
<Grid.Column textAlign="center" width={4} color="violet">
<h3>Content</h3>
</Grid.Column>
</Grid.Row>
</Grid>
</Container>
推荐阅读
- asp.net - ASP.NET Web 窗体和 React
- javascript - TypeError:“data”参数必须是字符串类型或 Buffer、TypedArray 或 DataView 的实例。收到 IncomingMessage 的一个实例
- windows - 无法获得正确的打印机状态
- java - com.predic8.soamodel.TypeRefAccessException 在为 WSDL 创建 SOAP 请求模板时
- docusignapi - 签名工具不适用于嵌入式签名
- java - Android - Firebase 实时数据库参考指向无效的 url
- python - matplolib 子图的大小调整
- google-cloud-platform - 提交后,Google OAuth 同意屏幕停留在“需要验证”
- pandas - Python - Plotly,Dash 问题 - 基于值的自定义标签和颜色
- xcode - 为什么我不能使用 brew 命令安装 watchman?