如何对齐中心列表图像

how to align center list images

我需要将我的 li 图片居中对齐。我试过 style="text-align: center;"在 ul 组件中。 但它没有用。提前致谢。

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" integrity="sha512-KfkfwYDsLkIlwQp6LFnl8zNdLGxu9YAA1QvwINks4PhcElQSvqcyVLLD9aMhXd13uQjoXtEKNosOWaZqXgel0g==" crossorigin="anonymous" referrerpolicy="no-referrer" />

<ul class="portfolioContainer row" style="text-align: center;">

  <li class="za  col-xs-6 col-sm-6 col-md-6 col-lg-4">
    <div class="lightCon"> <span class="hoverBox"> <span class="smallIcon"> <a rel="lightbox-demo" href="https://via.placeholder.com/50x50.png?text=1.jpg" title=" " class="zoom lb lb_warsaw1"><i class="fa fa-plus fa-2x" style="display: block;"></i></a> </span> </span> <img src="https://via.placeholder.com/50x50.png?text=1.jpg" alt=""> </div>
  </li>
  <li class="za  col-xs-6 col-sm-6 col-md-6 col-lg-4">
    <div class="lightCon"> <span class="hoverBox"> <span class="smallIcon"> <a rel="lightbox-demo" href="https://via.placeholder.com/50x50.png?text=2.jpg" title=" " class="zoom lb lb_warsaw1"><i class="fa fa-plus fa-2x" style="display: block;"></i></a> </span> </span> <img src="https://via.placeholder.com/50x50.png?text=2.jpg" alt=""> </div>
  </li>
  <li class="za  col-xs-6 col-sm-6 col-md-6 col-lg-4">
    <div class="lightCon"> <span class="hoverBox"> <span class="smallIcon"> <a rel="lightbox-demo" href="https://via.placeholder.com/50x50.png?text=3.jpg" title=" " class="zoom lb lb_warsaw1"><i class="fa fa-plus fa-2x" style="display: block;">  </i></a> </span> </span> <img src="https://via.placeholder.com/50x50.png?text=3.jpg" alt=""> </div>
  </li>
  <li class="za  col-xs-6 col-sm-6 col-md-6 col-lg-4">
    <div class="lightCon"> <span class="hoverBox"> <span class="smallIcon"> <a rel="lightbox-demo" href="https://via.placeholder.com/50x50.png?text=4.jpg" title=" " class="zoom lb lb_warsaw1"><i class="fa fa-plus fa-2x" style="display: block;"></i></a> </span> </span> <img src="https://via.placeholder.com/50x50.png?text=4.jpg" alt=""> </div>
  </li>
  <li class="za  col-xs-6 col-sm-6 col-md-6 col-lg-4">
    <div class="lightCon"> <span class="hoverBox"> <span class="smallIcon"> <a rel="lightbox-demo" href="https://via.placeholder.com/50x50.png?text=5.jpg" title=" " class="zoom lb lb_warsaw1"><i class="fa fa-plus fa-2x" style="display: block;"></i></a> </span> </span> <img src="https://via.placeholder.com/50x50.png?text=5.jpg" alt=""> </div>
  </li>
  <li class="za  col-xs-6 col-sm-6 col-md-6 col-lg-4">
    <div class="lightCon"> <span class="hoverBox"> <span class="smallIcon"> <a rel="lightbox-demo" href="https://via.placeholder.com/50x50.png?text=6.jpg" title=" " class="zoom lb lb_warsaw1"><i class="fa fa-plus fa-2x" style="display: block;"></i></a> </span> </span> <img src="https://via.placeholder.com/50x50.png?text=6.jpg" alt=""> </div>
  </li>
  <li class="za  col-xs-6 col-sm-6 col-md-6 col-lg-4">
    <div class="lightCon"> <span class="hoverBox"> <span class="smallIcon"> <a rel="lightbox-demo" href="https://via.placeholder.com/50x50.png?text=7.jpg" title=" " class="zoom lb lb_warsaw1"><i class="fa fa-plus fa-2x" style="display: block;"></i></a> </span> </span> <img src="https://via.placeholder.com/50x50.png?text=7s.jpg" alt=""> </div>
  </li>
  <li class="za  col-xs-6 col-sm-6 col-md-6 col-lg-4">
    <div class="lightCon"> <span class="hoverBox"> <span class="smallIcon"> <a rel="lightbox-demo" href="https://via.placeholder.com/50x50.png?text=8.jpg" title=" " class="zoom lb lb_warsaw1"><i class="fa fa-plus fa-2x" style="display: block;"></i></a> </span> </span> <img src="https://via.placeholder.com/50x50.png?text=8.jpg" alt=""> </div>
  </li>
</ul>

你可以使用 flex-box o 网格

ul {
  display: grid;
  place-items: center;
}

ul {
  display: flex;
  align-items: center;
  justify-content: center;
}