[英]how to create multi level ul li in horizontal
I am trying to develop ul
li
horizontally where parent will be vertical and child will be align besides them horizontally 我正在尝试水平开发
ul
li
,其中父母将是垂直的,孩子将在他们旁边水平对齐
code 码
<ul id="horizontal-list" class="horizontal-list">
<li>Motors</li>
<?php
$query = $this->db->get('countries');
$countries = $query->result();
foreach ($countries as $value) { ?>
<?php if (isset($_GET['country']) && in_array($value->id, @$_GET['country'])) { ?>
<li class="">
<span><?= (in_array($value->id, @$_GET['country'])) ? $value->name : null ?>
<a class="button" id="<?= $value->id ?>" name="country" style="color: white">×</a>
<?php
$query = $this->db->get('cities');
$city = $query->result();
foreach ($city as $city_value) { ?>
<?php if (isset($_GET['city']) && in_array($city_value->id, @$_GET['city'])) {
if ($city_value->country_id == $value->id) {
?>
<li class="btn-primary btn-xs">
<span><?= (in_array($city_value->id, @$_GET['city'])) ? $city_value->name : null ?>
<a class="button" id="<?= $city_value->id ?>" name="city" style="color: white">×</a>
</span>
</li>
<?php }
}
} ?>
</span>
</li>
<br/>
<?php } ?>
<?php } ?>
</ul>
css 的CSS
<style>
ul {
list-style-type: none;
}
ul.horizontal-list {
display: flex;
}
ul.horizontal-list ul.subhorizontal-list {
display: flex;
flex-direction: row;
}
</style>
result: 结果:
country city country city country city
what i want 我想要的是
country city
country city
country city
Use flex-direction:column... 使用flex-direction:column ...
ul { list-style-type: none; } ul.horizontal-list { display: flex; flex-direction:column; } ul.horizontal-list ul.subhorizontal-list { display: flex; flex-direction: row; }
<ul class="horizontal-list"> <li>country city</li> <li>country city</li> <li>country city</li> </ul> |
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.