html - 如何强制一行及其列使用其父元素高度的 100% (jumbotron)
问题描述
所以我想将标语垂直和水平对齐到jumbotron,顶部标志在正确的位置,小同型应该一直在jumbotron的底部。
任何帮助是极大的赞赏。
#hero {
height: 50vh;
background-image: url("/img/background.png");
background-size: cover;
background-repeat: no-repeat;
padding-top: 0.5em;
padding-bottom: 0.5em;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4"
crossorigin="anonymous">
<link rel="stylesheet" href="/css/custom.css">
<title>Document</title>
</head>
<body>
<div class="jumbotron jumbotron-fluid" id="hero">
<div class="container">
<div class="row">
<div class="col-12 text-left align-top h-25">
<img src="/img/toplogo.png" alt="">
</div>
<div class="col-12 text-center align-middle h-auto">
<img src="img/slogan.png" alt="">
</div>
<div class="col-12 text-right align-bottom test">
<img src="/img/logowhite.png" alt="">
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm"
crossorigin="anonymous"></script>
</body>
</html>
解决方案
如果我是正确的,您要求将标语垂直对齐中心并将同种型对齐到底部,如上图所示。您可以将以下内联样式部分添加到口号和小同型。
将标语对齐到中间:
<img src="img/slogan.png" alt="" style="top:--height from the top-- ;">
或者
<img src="img/slogan.png" alt="" style="display: flex; flex-direction: column; justify-content: center;">
要将小同型设置为底部:
<img src="/img/logowhite.png" alt="" style="top:--height from the top-- ;">
或者
<img src="img/logowhite.png" alt="" style="display: flex; flex-direction: column; justify-content: center;">
我想,这对你有用。
推荐阅读
- git - 如何将外部存储库中的单个文件提取到我当前的项目中?
- flutter - Flutter ListTile 崩溃问题
- r - 将多个 csv 文件(类似列)与 r 中的选择性行和列合并为一个
- c# - 如何向存在重复条目的视图发送消息?
- c++ - 使用流在 C++ 中记录信息
- sorbet - 我应该如何解决自动生成的 RBI 文件中的合并冲突?
- javascript - 我可以缩短这个三元语句吗?
- vue.js - 修改自动完成或复制 vuetify 样式?
- r - 如何让我的 shinyApp 读取我的数据文件?
- google-apps-script - 将值设置为 40 个单元格,同时在每组之间等待 3 秒