简体   繁体   English

谁能帮我弄清楚为什么我不能将我的粘性顶部导航栏更改为左侧? CSS

[英]can anyone help me figure out why can't I change my sticky top navbar to left? CSS

I wanted to change the position of my navbar on my portfolio but after many tries it just doesn't work for me, either it completely vanishes or stays in the same place.我想在我的投资组合中更改我的导航栏的 position 但经过多次尝试它对我不起作用,它要么完全消失,要么留在同一个地方。 Could anyone look into the code and tell me what to modify?任何人都可以查看代码并告诉我要修改什么吗? Down below I'm posting my code with top navbar.下面我用顶部导航栏发布我的代码。

css

body {
  margin: 0;
  width: 100%;
  font-family: "Quicksand", sans-serif;
  background: #dbdbdb;
  z-index: 1;
}

.container {
  font-weight: 750;
  width: 100%;
  color: white;
  background-color: #b3b3b3;
  z-index: 5;
  overflow: hidden;
  position: fixed;
  position: -webkit-sticky;
  top: 0px;
  margin-bottom: 20px;
  white-space: nowrap;
  top: 0;
  background-image: linear-gradient(bottom, #dbdbdb 2%, #b3b3b3 60%);
  background-image: -moz-linear-gradient(bottom, #dbdbdb 2%, #b3b3b3 60%);
}

header {
  background-color: #b3b3b3;
  z-index: 5;
}

header::after {
  content: "";
  display: table;
  clear: both;
}

.logo {
  float: left;
  padding: 10px 0;
  z-index: 5;
}
img {
  float: left;
  width: 90px;
  height: 70px;
  padding-top: 10px;
}
nav {
  float: right;
  top: 0;
  margin-right: 8%;
}

nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

nav li {
  display: inline-block;
  margin-left: 70px;
  padding-top: 23px;

  position: relative;
}

nav a {
  color: rgb(80, 80, 80);
  text-decoration: none;
  text-transform: uppercase;
  font-size: 13px;
  display: inline-block;
}

nav a:hover {
  color: rgb(140, 140, 140);
}

nav a::before {
  content: "";
  display: block;
  height: 5px;
  background-color: rgb(140, 140, 140);

  position: absolute;
  top: 0;
  width: 0%;

  transition: all ease-in-out 250ms;
}

nav a:hover::before {
  width: 100%;
}
html

<header>
        <div class="container">    
            <nav>
              <ul>
                <li><a href="#history">.history</a></li>
                <li><a href="#">.aboutme</a></li>
                <li><a href="#">.skills</a></li>
                <li><a href="#">.aspirations</a></li>
              </ul>
            </nav>
          </div>
    </header>

I'd like to keep my hover animation but now come to think of it, the bar could be on the side now.我想保留我的 hover animation 但现在想想,酒吧现在可能在一边。 I'll fix that myself.我会自己解决的。

If I understood correctly the problem just add the following to your css:如果我理解正确,只需将以下内容添加到您的 css 中:

* {
  margin: 0;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我的导航栏“位置问题”已停止工作,我不知道为什么 - My navbar “position sticky” has stopped working and I can't figure out why 当导航栏到达页面顶部时,我的粘性标头会导致随后的div跳到100像素左右,无法找出解决方法吗? - My sticky header causes the subsequent div to jump about 100 pixels when the navbar reaches the top of the page, can't figure out a fix? 谁能帮我弄清楚为什么我无法让jQuery震动效果在我的div上起作用? - Can anyone help me in figuring out why I can't get Jquery shake effect to work on my div? CSS-有人可以帮助我找出下拉菜单导航出现的问题吗? - CSS - Can someone help me figure out where I went wrong with my dropdown menu nav? 有人能帮我弄清楚为什么我的ul不会变成横向导航? 谢谢 :) - Can someone help me figure out why my ul isn't turning into horizontal navigation? thanks :) 谁能帮我修复CSS? - Can anyone help me fix my css? 谁能帮我找出这个图库插件为何具有这种方式? - Can anyone help me figure out why this gallery plugin is behaving this way? 有人可以告诉我为什么我的CSS无法与html链接吗? 我不知道自己在做什么错? - Can someone please tell me why my css won't link with html? I can't figure out what I'm doing wrong? 我不知道为什么页面跳到顶部 - I can't figure out why the page is jumping to the top 谁能帮我弄清楚为什么我的HTML电子邮件在IE / Chrome中看起来有所不同? - Can anyone help figure out why my HTML email looks different in IE/Chrome?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM