我希望我的搜索栏和“相机搜索”比屏幕底部大约高出75%,因此从导航栏测量时应有25%的空白。我在垂直对齐时遇到问题。
我曾尝试在CSS文件中使用vertical-align: 25%
作为#search-header
的ID,但无济于事。
<!-- index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="Camera search."">
<meta name="author" content="author">
<title>Camera App</title>
<!-- Bootstrap core CSS -->
<link href="{% static 'core/vendor/bootstrap/css/bootstrap.min.css' %}" rel="stylesheet">
<link href="{% static 'core/css/custom.css' %}" rel="stylesheet">
<!-- Angolia search CDN and CSS -->
<script src="https://cdn.jsdelivr.net/algoliasearch/3/algoliasearch.min.js"></script>
</head>
<body>
<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark static-top">
<div class="container-fluid">
<a class="navbar-brand" href="/"><img alt="brand" src="{% static 'core/img/logo_with_tagline.png' %}" ></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home
<span class="sr-only">(current)</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Services</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</ul>
</div>
</div>
</nav>
<!-- Search section -->
<div id="search-header" class="container-fluid">
<div class="row">
<div class="col-xl-9 text-center mx-auto">
<h3>Camera search</h3>
</div>
</div>
<div class="row">
<div class="col-sm-8 col-xl-5 ais-InstantSearch mx-auto">
<input id="searchbow" name="q" placeholder="Search" autocomplete="off" autocorrect="false" spellcheck="false" class="form-control" type="search" />
</div>
<div id="hits"></div>
</div>
</div>
<section class="hits">
<div class="container">
<div class="row">
<div class="col-xl-9 text-center">
<h1>text</h1>
</div>
</div>
</div>
</section>
<!-- Bootstrap core JavaScript -->
<script src="{% static 'core/vendor/jquery/jquery.slim.min.js' %}"></script>
<script src="{% static 'core/vendor/bootstrap/js/bootstrap.bundle.min.js' %}"></script>
<script src="//cdn.jsdelivr.net/jquery/2.1.4/jquery.js"></script>
<script src="//cdn.jsdelivr.net/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="//cdn.jsdelivr.net/g/algoliasearch,algoliasearch.helper"></script>
<script src="{% static 'core/js/search.js' %}"></script>
</body>
</html>
/* custom.css */
.navbar-brand > img {
max-height: 40px;
}
#search-header {
vertical-align: 25%;
}
以下是截至目前的结果:https://jsfiddle.net/3tf780np/ 这是我正在尝试实现的类似图像,除非没有大文本显示“远程作业列表”。
答案 0 :(得分:3)
U可以在搜索标题上使用margin-top而不是vertical-align来调整与导航栏的间距