在不同的屏幕尺寸下将 Flex 项目对齐在 Bootstrap 的末尾
使用 .justify-content-*-end 类将弹性项目对齐在不同屏幕尺寸的末尾,如下所示 −
对于小屏幕尺寸,使用 −
justify-content-sm-end
对于中等屏幕尺寸,使用 −
justify-content-md-end
对于大屏幕尺寸,使用 −
justify-content-lg-end
让我们看看如何在小、中和大屏幕尺寸下水平对齐弹性项目 −
范例
<!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://ajax.googleapis.com/ajax/libs/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"> <h3>Form of Tea</h3> <div class="d-flex justify-content-sm-end bg-secondary mb-5"> <div class="p-2 bg-warning">Black Tea</div> <div class="p-2 bg-info">Green Tea</div> <div class="p-2 bg-secondary">Indian Tea</div> </div> <div class="d-flex justify-content-md-end bg-secondary mb-5"> <div class="p-2 bg-info">Black Tea</div> <div class="p-2 bg-danger">Green Tea</div> <div class="p-2 bg-secondary">Indian Tea</div> </div> <div class="d-flex justify-content-lg-end bg-secondary mb-5"> <div class="p-2 bg-primary">Black Tea</div> <div class="p-2 bg-warning">Green Tea</div> <div class="p-2 bg-danger">Indian Tea</div> </div> </div> </body> </html>
广告