html - 为什么我的 h1 元素出现在 header-image 后面,尽管它是在 header 元素下面定义的?
问题描述
为什么我的 h1 元素出现在 header-image 后面,尽管它是在 header 元素下面定义的?
header {
display: flex;
position: fixed;
height: 75px;
width: 100%;
}
.logo {
width: 60vw;
}
#header-img {
width: auto;
height: 100%;
}
<header id="header">
<div class="logo"><img id="header-img" src="https://s8.postimg.cc/kxr6hl1v9/logo.png"></img>
</div>
</header>
<div>
<h1>hello i'm vivek dalsaniya</h1>
</div>
解决方案
<header>
是position: fixed
。_ 任何不是position: static
(默认)或position: relative
脱离正常流程且不影响非其后代元素的布局的元素。
推荐阅读
- r - 运行飞机探测模拟
- python - 如何定义一个包容性的值范围?
- javascript - Javascript Firebase Firestore 返回无序数据
- javascript - MongoDB 聚合 - 组合集合 A 中文档的多个值以在集合 B 的文档中查找单个值
- python - VS Code 没有运行 Python 程序
- javascript - JavaScript 将字符串转换为运算符
- c++ - 在从不调用 asio::io_conterxt.run() 的线程中,我必须调用 post() 将任务分派给调用 io_context.run() 的线程吗?
- sql - 在 SQL 中使用 concat 或子字符串添加字母 X
- reactjs - 如何避免在 React 中无限滚动的情况下重新渲染列表?
- sql - 相同的 SQL 在两个数据库中以非常不同的速度运行