[英]Header display overlaps with adjacent Elements (HTML/CSS)
In my website, I have a layout like this: 在我的网站上,我的布局是这样的:
<header>
{Dropdown nav menu consisting of <nav>, <ul> and <li> }
</header>
<div>
{content}
</div>
However, the header overlaps with the div, as if the div content were a background element with a lower z-index. 但是,标头与div重叠,就好像div内容是z索引较低的背景元素一样。 I can fix this by changing the HTML:
我可以通过更改HTML来解决此问题:
<div>
{Dropdown menu consisting of <nav>, <ul> and <li> }
</div>
<div>
{content}
</div>
Why does this happen, and is there a way to get blocking behavior w/ the header element? 为什么会发生这种情况,并且有一种方法获得带有标题元素的阻塞行为? I've toyed w/ the header's position, display, z-index, etc but haven't been able to have any effect.
我弄过w /标头的位置,显示,z-index等,但没有任何效果。
Per https://www.w3schools.com/tags/tag_header.asp : 根据https://www.w3schools.com/tags/tag_header.asp :
Most browsers will display the element with the following default values:
大多数浏览器将使用以下默认值显示元素:
header {
display: block;
}
Try removing/adjusting margin/padding from the <nav>
, <ul>
and <li>
until you discover what is throwing your layout off. 尝试从
<nav>
, <ul>
和<li>
删除/调整边距/填充,直到发现导致布局问题的地方。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.