使用Bootstrap 4中的flex-column-reverse类反转flex项目的顺序。
设置flex-column-reverse类,如下所示-
<div class="d-flex flex-column-reverse">
添加flex项目以包含在Bootstrap 4中-
<div class="d-flex flex-column-reverse"> <div class="p-2 bg-secondary">Demo 1</div> <div class="p-2 bg-danger">Demo 2</div> <div class="p-2 bg-info">Demo 3</div> </div>
以下是实现flex-column-reverse类的示例-
<!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css"> <script src="https://cdn.staticfile.org/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script> </head> <body> <div class="container mt-3"> <h2>Implementing Column Reverse</h2> <div class="d-flex flex-column-reverse"> <div class="p-2 bg-secondary">Demo 1</div> <div class="p-2 bg-danger">Demo 2</div> <div class="p-2 bg-info">Demo 3</div> </div> </div> </body> </html>