Я пытаюсь создать область статистики для сайта. На настольном компьютере их должно быть два по горизонтали, а на мобильном устройстве - в стопку. Было бы неплохо, если бы содержимое самого внутреннего DIV было сложено, но я не могу понять, как это сделать.
Рабочий стол должен выглядеть примерно так
А мобильный примерно так
Вот мой код
.site-stats-wrap {
width: 100%;
margin-left: auto;
margin-right: auto;
background: pink;
margin-top: 10px;
margin-bottom: 10px;
}
@media only screen and (max-width: 500px) {
.site-stats-wrap {
width: 100%;
margin-left: auto;
margin-right: auto;
background: pink;
margin-top: 15px;
margin-bottom: 15px;
}
}
.site-stats-group {
width: 100%;
display: table;
}
.site-stat-title {
width: 50%;
float: left;
}
@media only screen and (max-width: 500px) {
.site-stat-title {
width: 100%;
float: left;
}
}
.site-stat-info {
width: 50%;
float: left;
}
@media only screen and (max-width: 500px) {
.site-stat-info {
width: 100%;
float: left;
}
}
.site-stat-title-display {
width: 80%;
margin-left: auto;
margin-right: auto;
text-align: center;
}
.site-stat-info-display {
width: 80%;
margin-left: auto;
margin-right: auto;
text-align: center;
margin-top: 20px;
margin-bottom: 20px;
}
.site-stat-title {
font-family: 'Roboto', sans-serif;
font-size: 35px;
line-height: normal;
margin: 0;
}
@media only screen and (max-width: 500px) {
.site-stat-title {
font-family: 'Roboto', sans-serif;
font-size: 25px;
line-height: normal;
margin: 0;
}
}
.site-stat-subtitle {
font-family: 'Roboto', sans-serif;
font-size: 30px;
line-height: normal;
margin: 0;
}
@media only screen and (max-width: 500px) {
.site-stat-subtitle {
font-family: 'Roboto', sans-serif;
font-size: 20px;
line-height: normal;
margin: 0;
}
}
<div class="site-stats-wrap">
<div class="site-stats-group">
<div class="site-stat-title">
<div class="site-stat-title-display">
<p class="site-stats-title">Statistics</p>
</div>
</div>
<div class="site-stat-info">
<div class="site-stat-info-display">
<p class="site-stat-title">Title</p>
<p class="site-stat-subtitle">A Short Description</p>
<br>
<p class="site-stat-title">Title</p>
<p class="site-stat-subtitle">A Short Description</p>
</div>
</div>
</div>
</div>
Проблемы, с которыми я сейчас сталкиваюсь: A) Содержимое каждого столбца не центрировано (на мобильном устройстве их высота просто определяется по содержимое, но должно быть той же высоты на рабочем столе внутри оболочки) B) Текст в разделе статистики не отображается в отдельной строке.
Любые ответы, которые центрируют содержимое и помогают решить проблему с текстом, будут оценен.
UPDATE
На основе ответа Эндрю Халперна .
.wrap {
width: 100%;
display: flex;
background: pink;
margin-top: 10px;
margin-bottom: 10px;
align-items: center;
justify-content: center;
flex-flow: row wrap;
text-align: center;
}
.col1 {
width: 50%;
}
@media only screen and (max-width: 500px) {
.col1 {
width: 100%;
}
}
.col2 {
width: 50%;
}
@media only screen and (max-width: 500px) {
.col2 {
width: 100%;
}
}
<div class="wrap">
<div class="col1">
<h1>I'm Centered</h1>
</div>
<div class="col2">
<h1>I'm Centered Too</h1>
<h1>I'm Centered Too</h1>
<h1>I'm Centered Too</h1>
</div>
</div>