Как расположить два контейнера по высоте на одном уровне
У меня есть главный контейнер, в котором находятся ещё два контейнера (один с списком ul, а второй с таблицей, и у меня не выходит выровнять их верхние границы на одном уровне, пробовал играть со свойствами display: flex, inline-block, и тд, но не вышло, можете подсказать как мне выровнять их на одном уровне?
HTML
<div class="container">
<div class="nav__second">
<ul>
<li><a href="/admins/adminsite/index.html">Создание товара</a></li>
<hr style="margin-left: -16%; width: 274px;">
<li><a href="#">Создание категории</a></li>
<hr style="margin-left: -16%; width: 274px;">
<li><a href="#">Создание подкатегории</a></li>
<hr style="margin-left: -16%; width: 274px;">
<li><a href="#">Настройка товара</a></li>
<hr style="margin-left: -16%; width: 274px;">
<li><a href="#">Настройка категории</a></li>
<hr style="margin-left: -16%; width: 274px;">
<li><a href="#">Настройка подкатегории</a></li>
</ul>
</div>
<div id="createtovar" class="create" >
<table>
<tr>
<th colspan="2" style="text-align: center; background-color: #008faf;"><input
style="width: 98%; height: 30px; text-align: center;" type="text"
placeholder="Название товара.">
</th>
</tr>
<tr>
<th>Стоимость: <input style="width: 70%; height: 30px;" type="text" placeholder="₽"></th>
<th>Единица измерения товара:
<select class="unit">
<option value="option0"></option>
<option value="option1">шт</option>
<option value="option2">кг</option>
<option value="option3">т</option>
<option value="option4">л</option>
<option value="option5">коробка</option>
</select>
</th>
</tr>
<tr>
<th>Изображение товара:</th>
<th><button style="width: 100%; height: 30px; background-color: #008faf; color: #fff;">Загрузить
изображение с
устройства</button></th>
</tr>
<tr>
<th>Описание товара:</th>
<th><textarea name="opisanie" style="width: 98.5%;" cols="30" rows="10"></textarea></th>
</tr>
<tr>
<th>Характеристики товара:</th>
<th><textarea name="haracteristika" style="width: 98.5%;" cols="30" rows="10"></textarea></th>
</tr>
<tr>
<th>Категория товара:</th>
<th>
<select>
<option>Выберите категорию</option>
<option>Категория 1</option>
<option> Подкатегории</option>
<option> Подкатегория 1</option>
<option> Подкатегория 2</option>
<option>Категория 2</option>
<option> Подкатегории</option>
<option> Подкатегория 1.2</option>
<option> Подкатегория 2.1</option>
</select>
</th>
</tr>
</table>
<button class="create-btn">Создать</button>
</div>
CSS свойства относящиеся к HTML коду:
.container {
display: flex;
width: 80%;
height: auto;
max-width: 1200px;
margin: 0 auto;
justify-content: center;
align-items: flex-start;
margin-top: 5%;
}
.nav__second {
max-width: 280px;
margin-bottom: auto;
}
.nav__second ul {
list-style: none;
background-color: #008faf;
}
.nav__second li {
padding: 4% 4%;
}
.nav__second a {
text-decoration: none;
color: #fff;
display: block;
font-size: 20px;
}
.create {
width: 100%;
text-align: center;
margin-bottom: auto;
}
Ответы (1 шт):
Автор решения: UModeL
→ Ссылка
Для многих элементов, у браузеров есть стили по умолчанию. Конкретно в вашем случае, список имеет внешние отступы, поэтому ему достаточно прописать свойство margin: 0 и проблема решится:
.container {
display: flex;
width: 80%;
height: auto;
max-width: 1200px;
margin: 0 auto;
justify-content: center;
align-items: flex-start;
margin-top: 5%;
}
.nav__second {
max-width: 280px;
margin-bottom: auto;
}
.nav__second ul {
list-style: none;
margin: 0;
background-color: #008faf;
}
.nav__second li {
padding: 4% 4%;
}
.nav__second a {
text-decoration: none;
color: #fff;
display: block;
font-size: 20px;
}
.create {
width: 100%;
text-align: center;
margin-bottom: auto;
}
.create table {
border-collapse: collapse;
}
<div class="container">
<div class="nav__second">
<ul>
<li><a href="/admins/adminsite/index.html">Создание товара</a></li>
<hr style="margin-left: -16%; width: 274px;">
<li><a href="#">Создание категории</a></li>
<hr style="margin-left: -16%; width: 274px;">
<li><a href="#">Создание подкатегории</a></li>
<hr style="margin-left: -16%; width: 274px;">
<li><a href="#">Настройка товара</a></li>
<hr style="margin-left: -16%; width: 274px;">
<li><a href="#">Настройка категории</a></li>
<hr style="margin-left: -16%; width: 274px;">
<li><a href="#">Настройка подкатегории</a></li>
</ul>
</div>
<div id="createtovar" class="create">
<table>
<tr>
<th colspan="2" style="text-align: center; background-color: #008faf;"><input style="width: 98%; height: 30px; text-align: center;" type="text" placeholder="Название товара.">
</th>
</tr>
<tr>
<th>Стоимость: <input style="width: 70%; height: 30px;" type="text" placeholder="₽"></th>
<th>Единица измерения товара:
<select class="unit">
<option value="option0"></option>
<option value="option1">шт</option>
<option value="option2">кг</option>
<option value="option3">т</option>
<option value="option4">л</option>
<option value="option5">коробка</option>
</select>
</th>
</tr>
<tr>
<th>Изображение товара:</th>
<th><button style="width: 100%; height: 30px; background-color: #008faf; color: #fff;">Загрузить
изображение с
устройства</button></th>
</tr>
<tr>
<th>Описание товара:</th>
<th><textarea name="opisanie" style="width: 98.5%;" cols="30" rows="10"></textarea></th>
</tr>
<tr>
<th>Характеристики товара:</th>
<th><textarea name="haracteristika" style="width: 98.5%;" cols="30" rows="10"></textarea></th>
</tr>
<tr>
<th>Категория товара:</th>
<th>
<select>
<option>Выберите категорию</option>
<option>Категория 1</option>
<option> Подкатегории</option>
<option> Подкатегория 1</option>
<option> Подкатегория 2</option>
<option>Категория 2</option>
<option> Подкатегории</option>
<option> Подкатегория 1.2</option>
<option> Подкатегория 2.1</option>
</select>
</th>
</tr>
</table>
<button class="create-btn">Создать</button>
</div>