javascript - 位置 div 之间的空间:相对
问题描述
我正在构建一个位于标题上方的导航面板。我使用postion: relative
并子跟踪了几个像素(#navigation)。
部分标题的高度是保留的,就好像导航面板没有移动一样。我希望该部分更接近标题而没有中断。
我该怎么做?
body {
background-color: #e6e6e6;
}
#conteiner {
border: 1px solid black;
}
#conteiner>* {
min-height: 100px;
display: flex;
}
/* HEADER */
header {
flex-direction: column;
align-items: center;
}
#spacer-up {
background-color: #8dc63f;
height: 15px;
width: 100%;
}
#frame-header {
max-height: 400px;
flex-direction: column;
align-items: center;
}
#spacer-down {
background-color: #dddddd;
height: 15px;
width: 100%;
}
#navigation {
width: 450px;
height: 130px;
display: flex;
position: relative;
top: -65px;
}
.button1 {
flex: 1;
background-color: #00984a;
display: flex;
align-items: center;
justify-content: center;
color: #FFF;
transition: 0.1s;
}
.button1:hover {
background-color: #007639;
transition: 0.2s;
}
/* Content */
section {
display: flex;
justify-content: center;
position: relative;
}
#content {
border: 1px solid black;
width: 1200px;
background-color: #FFF;
}
footer {
background-color: #007639;
justify-content: center;
align-items: center;
}
<body>
<!-- Add your site or application content here -->
<div id="conteiner">
<header>
<div id="spacer-up"></div>
<div id="frame-header">
<img src="/img/header-background.png" alt="" width="1138" height="369">
</div>
<div id="spacer-down"></div>
<div id="navigation">
<div class="button1">TEXT1</div>
<div class="button1">TEXT2</div>
<div class="button1">TEXT3</div>
</div>
</header>
<section>
<div id="content">
SECTION 1
</div>
</section>
<footer>
FOOTER
</footer>
</div>
<body>
解决方案
推荐阅读
- reactjs - 如何在另一个数据的特定部分显示额外的数据数组?
- python - PySpark:读取 pyspark 框架中的 csv 数据。为什么它在框架中显示特殊字符?以表格形式显示的任何方式,除了使用 pandas
- javascript - 如何在 Javascript 中停止重复数组?
- tensorflow - 将元组列表转换为 Tensorflow 张量
- mysql - 基于 mysql 视图结果创建表以加快获取速度
- spring-boot - Spring kafka 消费者滞后指标始终为 0
- ruby-on-rails - 升级 ruby 后得到:找不到符号:__ZN6libdap5ErrorD1Ev
- opencv - 我应该如何在 cv::cuda::GpuMat 上创建这样的掩码?
- python - 按自定义值对 Pandas 数据框进行排序
- python - 替换 yaml 文件 python 中的标记