18910140161

HTML/CSS-下拉菜单没有级联堆栈溢出

顺晟科技

2022-10-19 11:52:46

91

目前正在创建一个下拉菜单,在设计样式时,我似乎破坏了菜单的实际下拉功能,其余按钮不下拉,或者只有少数按钮下拉,我正在绞尽脑汁试图修复它,但没有取得任何进展。

如果可能的话,我希望按钮垂直放置,例如,如果您突出显示请求,您将得到:

  • 提交新请求
  • 打开请求
  • 已关闭的请求

如能协助纠正错误,将不胜感激。

抱歉,如果代码有点乱,这是一个正在进行的早期工作,还需要进行一些整理!


顺晟科技:

位置绝对的一切问题

尝试以下操作

在HTML代码中遵循此代码段样式。

  1. 导航菜单片段

    <html><head><style>body {
      font: normal normal bold 16px trebuchet ms;
      border: 0;
      text-align: center;
    }
    
    .nv {
      background: #4d9fb1;
      background: -webkit-gradient(linear, left top, left bottom, from(#4d9fb1), to(#2f626d));
      background: -moz-linear-gradient(top, #4d9fb1, #2f626d);
      background: linear-gradient(to bottom, #4d9fb1, #2f626d);
      padding: 0;
      width: 100%;
      display: flex;
      justify-content: center;
      text-decoration: none;
      margin: 0px;
    }
    
    .nv a {
      font-size: 16px;
      color: white;
      text-align: center;
      padding: 14px 16px;
      text-decoration: none;
      display: flex;
    }
    
    .snv {
      text-align: center;
      float: left;
    }
    
    .snv .snvbtn {
      font-size: 16px;
      border: none;
      outline: none;
      color: white;
      padding: 14px 16px;
      background: inherit;
      font: inherit;
      margin: 0;
    }
    
    .nv a:hover,
    .snv:hover .snvbtn {
      background: white;
      color: #3B7A8B;
      margin-left: auto;
      padding-left: auto;
      padding-right: auto;
    }
    
    .snv-content {
      display: none;
      position: absolute;
      background: #4d9fb1;
      background: -webkit-gradient(linear, left top, left bottom, from(#4d9fb1), to(#2f626d));
      background: -moz-linear-gradient(top, #4d9fb1, #2f626d);
      background: linear-gradient(to bottom, #4d9fb1, #2f626d);
      width: inherit;
      z-index: 1;
      color: white;
    }
    
    .snv-content a {
      display: inline-block;
      color: white;
      text-decoration: none;
    }
    
    .snv-content a:hover {
      background: white;
      color: #3B7A8B;
    }
    
    .snv:hover .snv-content {
      display: block;
    }
    
    .nv li {
      border-right: 3px solid #ffffff;
      display: inline-block;
      float: left;
      padding: 0px;
      overflow: hidden;
    }
    
    .nv li:last-child {
      border-right: 0;
    }
    
    .nv li>a {
      color: white;
      font-family: Trebuchet MS;
      font-size: 16px;
      font-weight: bold;
      line-height: 19px;
    }
    
    </style></head>

2)导航菜单样式表HTML代码段

//编写导航菜单代码段的规则

<html><head><style>body {
  font: normal normal bold 16px trebuchet ms;
  border: 0;
  text-align: center;
}

.nv {
  background: #4d9fb1;
  background: -webkit-gradient(linear, left top, left bottom, from(#4d9fb1), to(#2f626d));
  background: -moz-linear-gradient(top, #4d9fb1, #2f626d);
  background: linear-gradient(to bottom, #4d9fb1, #2f626d);
  padding: 0;
  width: 100%;
  display: flex;
  justify-content: center;
  text-decoration: none;
  margin: 0px;
}

.nv a {
  font-size: 16px;
  color: white;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
  display: flex;
}

.snv {
  text-align: center;
  float: left;
}

.snv .snvbtn {
  font-size: 16px;
  border: none;
  outline: none;
  color: white;
  padding: 14px 16px;
  background: inherit;
  font: inherit;
  margin: 0;
}

.nv a:hover,
.snv:hover .snvbtn {
  background: white;
  color: #3B7A8B;
  margin-left: auto;
  padding-left: auto;
  padding-right: auto;
}

.snv-content {
  display: none;
  position: absolute;
  background: #4d9fb1;
  background: -webkit-gradient(linear, left top, left bottom, from(#4d9fb1), to(#2f626d));
  background: -moz-linear-gradient(top, #4d9fb1, #2f626d);
  background: linear-gradient(to bottom, #4d9fb1, #2f626d);
  width: inherit;
  z-index: 1;
  color: white;
}

.snv-content a {
  display: inline-block;
  color: white;
  text-decoration: none;
}

.snv-content a:hover {
  background: white;
  color: #3B7A8B;
}

.snv:hover .snv-content {
  display: block;
}

.nv li {
  border-right: 3px solid #ffffff;
  display: inline-block;
  float: left;
  padding: 0px;
  overflow: hidden;
}

.nv li:last-child {
  border-right: 0;
}

.nv li>a {
  color: white;
  font-family: Trebuchet MS;
  font-size: 16px;
  font-weight: bold;
  line-height: 19px;
}

</style></head>

从上面的HTML代码片段,根据您的要求替换超链接,并再次运行它。确保为每个标记指定正确的类名,并在CSS文件中保持相同,否则将无法工作。

  • TAG:
相关文章
我们已经准备好了,你呢?
2024我们与您携手共赢,为您的企业形象保驾护航