Мне нужно, чтобы текст оставался внутри красного поля, предпочтительно выровненный по верхней части красного поля.
Тогда мне нужно красное поле и его текст по центру синего поля.
Код: Выделить всё
.large-box {
width: 300px;
height: 300px;
background-color: rgb(62, 118, 221); /* Sets the background color */
border: 3px solid black; /* Adds a border for visibility */
padding: 10px;
margin: 20px;
color: white; /* Sets the text color inside the box */
text-align: center;
line-height: 100px; /* Vertically centers text for single line */
display: flex;
justify-content: center;
align-items: center;
}
.small-box {
width: 75px;
height: 75px;
background-color: rgb(250, 99, 124);
border: 5px solid rgb(80, 31, 31);
padding-left: 3px;
padding-bottom: 10px;
word-wrap: break-word;
color: black;
display: flex;
justify-content: center;
}Код: Выделить всё
center this div
Подробнее здесь: https://stackoverflow.com/questions/797 ... a-text-box
Мобильная версия