【问题标题】:can anyone help me figure out why can't I change my sticky top navbar to left? CSS谁能帮我弄清楚为什么我不能将我的粘性顶部导航栏更改为左侧? CSS
【发布时间】:2021-03-18 18:45:04
【问题描述】:

我想更改我的导航栏在我的投资组合中的位置,但经过多次尝试后它对我不起作用,要么完全消失,要么留在同一个地方。任何人都可以查看代码并告诉我要修改什么吗? 在下方,我正在使用顶部导航栏发布我的代码。

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>

我想保留悬停动画,但现在想一想,栏现在可能在一边。我会自己解决。

【问题讨论】:

    标签: html css navbar


    【解决方案1】:

    如果我理解正确,只需将以下内容添加到您的 css 中:

    * {
      margin: 0;
    }
    

    【讨论】:

    • 嗨,它仍然没有解决导航栏从顶部转移到左侧的问题:(
    • 我不确定你的意思,你是说你想要一个侧边栏吗?
    • 是的,我想将我的导航栏从顶部转换为贴在左侧的侧边栏,水平旋转
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-23
    • 2011-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多