html - Align text in ReactJS in a proper way
问题描述
I am fairly new to HTML/CSS. I created a pop-up window with Modal which I now try to adjust. Also, I am using a CSS Style Sheet which looks like this:
.scoreboard {
position: absolute;
width: 300px;
height: 200px;
left: 450px;
top: 100px;
background: gold;
mix-blend-mode: normal;
border: 2px solid #25282B;
box-sizing: border-box;
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
border-radius: 10px;
text-align: center;
}
Then, the actual Modal looks like this:
<Modal
isOpen={this.state.isModalOpen}
onRequestClose={() => this.closeModal()}
className={'scoreboard'}
contentLabel="Example Modal"
>
{this.state.players.map(p => (
<div>
<p>Player: {p.username} Points:{p.points}</p>
</div>
))}
</Modal>
Now, as you can see I try to align the players name and score nicely, so that all the texts are properly ordered in the middle of .scoreboard. But at the moment it looks like this:
What would be the best way to align those texts so that they are placed in the middle of scoreboard and also have the same indents etc?
Thanks in advance and have a good one!
解决方案
使用位置:相对;而不是位置:绝对;
推荐阅读
- reactjs - 如何在 React Native 中删除 react-native-tts 异步函数的事件监听器
- c# - 登录请求重定向到 Account/Login?ReturnUrl
- powerbi - 使用 Power BI 在 PowerApps 中编写新条目
- python-3.x - 计算每日累积总和的最佳方法是什么?
- python - 减少树莓派到 arduino 串行通信的延迟
- terraform - Terraform:InvalidParameterException:PutSubscriptionFilter 操作无法与 vendor es 的 destinationArn 一起使用
- swift - 仅使用 .animation 修饰符的显式动画不起作用
- database - 如何将这 3 列合二为一?
- google-analytics - Google Analytics 如何计算页面停留时间?
- python - Tensorflow ValueError:找不到可以处理输入的数据适配器