저는 HTML / CSS를 처음 접합니다. Modal을 사용하여 팝업 창을 만들었는데 이제 조정하려고합니다. 또한 다음과 같은 CSS 스타일 시트를 사용하고 있습니다.
.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;
}
그러면 실제 모달은 다음과 같습니다.
<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>
이제 보시다시피 플레이어 이름과 점수를 잘 정렬하여 모든 텍스트가 .scoreboard 중간에 올바르게 정렬되도록합니다. 그러나 현재는 다음과 같이 보입니다.
점수 판 중간에 배치되고 동일한 들여 쓰기 등을 갖도록 텍스트를 정렬하는 가장 좋은 방법은 무엇입니까?
미리 감사드립니다.
점수 판 중간에 배치되고 동일한 들여 쓰기 등을 갖도록 텍스트를 정렬하는 가장 좋은 방법은 무엇입니까?
flexbox를 사용하면 컨테이너의 요소를 쉽게 정렬 할 수 있습니다.
.scoreboard {
background: yellow;
width: 250px;
height: 250px;
border: 1px solid;
/* FLEXBOX */
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.scoreboard p {
margin: 3px 0;
}
.scoreboard div span {
width: 80px;
display: inline-block;
padding-right: 5px;
}
<div class="scoreboard">
<div>
<p><span>Player: 1</span> Points: ()</p>
</div>
<div>
<p><span>Player: 1</span> Points: ()</p>
</div>
<div>
<p><span>Player: Bot</span> Points: ()</p>
</div>
<div>
<p><span>Player: Bot</span> Points: ()</p>
</div>
</div>
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다