最后在Bootstrap中的不同屏幕尺寸上对齐flex项目
使用.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://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">
<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>