Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 当我将position:absolute添加到导航栏时,justify content:space-between停止工作_Html_Css_Flexbox - Fatal编程技术网

Html 当我将position:absolute添加到导航栏时,justify content:space-between停止工作

Html 当我将position:absolute添加到导航栏时,justify content:space-between停止工作,html,css,flexbox,Html,Css,Flexbox,我试图有一个标题图像与导航栏是浮动在它上面 也就是说,css和html作为 <div class="header-container"> <!-- START HEADER IMAGE --> <section class="header-image"> <img src="./img/cntower.png"> </section> <!-- END HEADER IMAGE --> <!-- TOP L

我试图有一个标题图像与导航栏是浮动在它上面

也就是说,css和html作为

<div class="header-container">

<!-- START HEADER IMAGE -->
<section class="header-image">
  <img src="./img/cntower.png">
</section>

<!-- END HEADER IMAGE -->

<!-- TOP LEVEL NAVIGATION -->
<div class="navbar">
  <div>
    <p>
      <strong>GTA Wholesale</strong>
    </p>
  </div>

  <div>
    <p><strong>All</strong></p>
    <p><a>Published</a></p>
    <p><a>Drafts</a></p>
    <p><a>Deleted</a></p>
    <p><a>New</a></p>
  </div>
</div>

<!-- END TOP LEVEL NAVIGATION -->


</div>

在我的navbar类中,如果我删除position:absolute,它不会出现在我的图像的顶部,但是当存在position-absolute时,属性之间的空格不适用。如何解决此问题?

您可以保留
绝对
参数,并将
左:0
右:0
添加到
导航栏
类中

例如:

img {
  max-width 100%;
}

.header-container {
  display: flex;
  flex-direction: column;
  position: relative;
}

.navbar {
  position: absolute;
  display: flex;
  justify-content: space-between;
  top: 0;
}

.header-image {
  display: flex;
}

.header-image img {
  max-width: 100%;
}