下拉列表在sharepoint中偏离中心

时间:2019-06-25 13:14:29

标签: css

我的下拉链接没有居中,我似乎无法解决

我尝试了各种对齐方式,并且可以在线运行在html编辑器中,但不能在SharePoint上运行。下拉链接似乎总是落在菜单右侧约20px处,这很奇怪,它不仅在SharePoint上发生,而且在其他地方起作用。

body {
  margin: 0;
}

.topnav {
  background-color: black;
  height: 50px;
  position: fixed;
  top: 0px;
  left: 340px;
  width: 1000px;
}

.dropbtn {
  background-color: black;
  color: white;
  padding: 16px;
  font-size: 16px;
  border: none;
  height: 50px;
  z-index: 100;
  width: 160px;
}

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-content {
  display: none;
  position: absolute;
  background-color: #f1f1f1;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
  z-index: 1;
}

.dropdown-content a {
  color: white;
  background-color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
}

.dropdown-content a:hover {
  background-color: white;
  color: black;
}

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

.dropdown:hover .dropbtn {
  background-color: white;
  color: black;
}
<div class="topnav">
  <div class="dropdown">
    <button class="dropbtn">Dropdown</button>
    <div class="dropdown-content">
      <a href="#">Link 1</a>
      <a href="#">Link 2</a>
      <a href="#">Link 3</a>
    </div>
  </div>
  <div class="dropdown">
    <button class="dropbtn">Dropdown</button>
    <div class="dropdown-content">
      <a href="#">Link 1</a>
      <a href="#">Link 2</a>
      <a href="#">Link 3</a>
    </div>
  </div>
</div>

0 个答案:

没有答案