html - 菜单按钮定位

标签 html css sass css-position

我目前正在关注这个 HTML/SCSS/JavaScript 教程:https://www.youtube.com/watch?v=7WaohfclZRs&list=PLillGF-RfqbYoGoCjKoMOkVznV6aSXKzU&index=3 .

我相信我做了视频中的所有操作,但我的菜单按钮位置不正确。

The menu btn is always positioned relative to the header element, even though I added a absolute position element to my menu btn.

.menu-btn {
  position: absolute;
  z-index: 3;
  cursor: pointer;
  right: 35px;
  top: 35px;
  @include ease-out;}

header {
  position: fixed;
  z-index: 2; }
<body id="bg-img">
    <div class="overlay"></div>
    <header>
      <div class="menu-btn">
        <div class="btn-line"></div>
        <div class="btn-line"></div>
        <div class="btn-line"></div>
      </div>
    </header>
</body>

前两个片段来 self 的 _menu.scss 和 main.scss 文件,最后一个片段来 self 的 index.html 文件。

Here's how it should look like

And here's how it is looking like right now

感谢您的帮助!!

最佳答案

如您所见。你的标题有点短......所以尝试添加 width: 100%; - 这应该使该菜单全宽。

header{
   width:100%;
}

关于html - 菜单按钮定位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58165997/

相关文章:

c# - 带有 Entity Framework 的 MVC 我的 DropDownList 不是下拉列表

html - css水平滚动查询

html - 一个窗体一个按钮和一个旋转加载器里面

javascript - 获取 webpack 入口点名称并在加载器中重用它

html - Bootstrap 4 SCSS 覆盖不起作用

php - Smarty 错误 : modifier 'unescape' is not implemented

c# - ASP.NET MVC : Align checkbox and label on same line

html - 如果 div 不存在,您可以在 CSS 中应用 CSS 规则吗?

html - 针对 css3 排除的目标 webkit 浏览器

html - SASS 的关键 CSS