因此,我是Bootstrap的新手,我刚刚尝试了该文档中的示例之一,但未按预期显示。
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB"
crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
crossorigin="anonymous"></script>
<div class="container">
<div class="row">
<div class="col align-self-start">
One of three columns
</div>
<div class="col align-self-center">
One of three columns
</div>
<div class="col align-self-end">
One of three columns
</div>
</div>
</div>
输出应如下所示(如果看不到图像,则为三个div,“三列之一”与左上,中和右下对齐)
但是我得到的只是三个div并排。
有什么我想念的吗?
答案 0 :(得分:1)
您需要为行提供高度-
<div class="row" style="height:500px;">
答案 1 :(得分:0)
签出
<div class="container">
<div class="row">
<div class="col-md-4 align-self-start">
One of three columns
</div>
</div>
<div class="row">
<div class="col-md-4 align-self-center">
</div>
<div class="col-md-4 align-self-center">
One of three columns
</div>
</div>
<div class="row">
<div class="col-md-4 align-self-center">
</div>
<div class="col-md-4 align-self-center">
</div>
<div class="col-4 align-self-end">
One of three columns
</div>
</div>
</div>
</div>
让我知道这是否有效吗?
答案 2 :(得分:0)
.align-self- *用于对齐弹性框
尝试一下;
<div class="container">
<div class="d-flex bg-light" style="height:150px;">
<div class=" align-self-start">Flex item 1</div>
<div class=" align-self-center">Flex item 2</div>
<div class=" align-self-end">Flex item 3</div>
</div>
</div>