css 如何将navbar放在这个位置[关闭]

mspsb9vt  于 11个月前  发布在  其他
关注(0)|答案(2)|浏览(83)

**已关闭。**此问题需要debugging details。目前不接受回答。

编辑问题以包括desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem。这将帮助其他人回答问题。
2天前关闭。
Improve this question
我不能使一个导航栏菜单适合在网络的位置,我尝试了很多次,但没有为我工作。有人能帮助我吗?
我如何才能使这个导航栏在这个位置:https://prnt.sc/pMAPPMmneH7x导航栏在照片中。
在这个例子中我使用了:display:flex;
align-items:居中;
justify-content:space-between;

pvabu6sv

pvabu6sv1#

您可以执行以下操作:
<header>标签中创建3个标签,然后使用flexbox。
例如:

header {
  display:flex;
  justify-content: space-between;
}

个字符
现在它应该工作!

ghhaqwfi

ghhaqwfi2#

这是我的方法(如果你有任何问题,请随时提问!):

/* Bright Colors are for debug !!! */

/* Setting font and variable that will be used everywhere */
:root {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  --dev-color: #5faedb;
}

/* Making sure the page cannot scroll left to right, only top to bottom */
body {
  overflow-x: hidden;
  overflow-y: auto;
}

/* Styling the navigation bar to contain 3 elements, .branding, .links, and .auth, */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-direction: row;
  width: 100%;
  height: 50px;
  top: 0;
  left: 0;
  background: var(--dev-color);
  position: fixed;
}

/* Styling container where logo is stored and styled */
.nav>.branding {
  margin: 0 0 0 20px;
  height: 100%;
}

.nav>.branding>a,
.nav>.branding>a>img {
  display: flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: 100%;
}

/* Un-Ordered list of links ( Navigation ) */
.nav>.links {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: row;
  list-style: none;
  margin: 0 10px 0 10px;
  padding: 0;
  height: 100%;
}

.nav>.links>li {
  margin: 10px;
}

.nav>.links>li>a {
  font-weight: 600;
  color: white;
  text-decoration: none;
  position: relative;
}

.nav>.links>li>a::after {
  content: "";
  width: 100%;
  height: 1px;
  left: 0;
  bottom: -5px;
  transform: scaleX(0);
  background: white;
  position: absolute;
}

.nav>.links>li>a:hover::after {
  transform: scaleX(1);
}

/* Authentication links ( Usually Sign in and Sign up ) */
.nav>.auth {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 10px 0 0;
  height: 100%;
  font-weight: 600;
}

.nav>.auth>a {
  color: white;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 20px;
  text-decoration: none;
}

个字符

相关问题