Html 如何在li元素之间设置相等的边距

Html 如何在li元素之间设置相等的边距,html,css,Html,Css,我想在导航中的“Li”元素之间设置相等的边距。 现在,两者之间存在着细微的差别 左右边距如下图所示 以下是css: .nav { background-color: white; width: 100%; min-height: 29px; line-height: 26px; border-top: solid 1px #999; border-bottom: solid 2px #333333; font-weight: bold; position: r

我想在导航中的“Li”元素之间设置相等的边距。 现在,两者之间存在着细微的差别 左右边距如下图所示

以下是css:

.nav {
  background-color: white;
  width: 100%;
  min-height: 29px;
  line-height: 26px;
  border-top: solid 1px #999;
  border-bottom: solid 2px #333333;
  font-weight: bold;
  position: relative;
  border: none;
  font-size: 15px;
  font-weight: normal;
}

.nav, .nav ul {
  padding: 0;
  margin: 0;
  list-style: none;
  line-height: 2.5;
  /* font-size: 13px; */
  z-index: 100;
}

.nav li {
  float: left;
}

.nav a {
  background-color: white;
  text-decoration: none;
  display: block;
  z-index: 9999;
  padding-right: 5px;
  padding-left: 5px;
}

.nav ul a {
  /* border-right: 1px solid #333333; */
  text-indent: 4px;
  padding-left: 4px;
  padding-top: 4px;
  padding-bottom: 4px;
  width: 6.5em;
  line-height: 16pt;
}

.nav > ul > li > a {
  width: 6em;
}

您可以尝试添加
字间距:5px

.nav {
  background-color: white;
  width: 100%;
  min-height: 29px;
  line-height: 26px;
  border-top: solid 1px #999;
  border-bottom: solid 2px #333333;
  font-weight: bold;
  position: relative;
  border: none;
  font-size: 15px;
  font-weight: normal;
  word-spacing: 5px;
}

希望这有帮助。

您可以尝试添加
单词间距:5px

.nav {
  background-color: white;
  width: 100%;
  min-height: 29px;
  line-height: 26px;
  border-top: solid 1px #999;
  border-bottom: solid 2px #333333;
  font-weight: bold;
  position: relative;
  border: none;
  font-size: 15px;
  font-weight: normal;
  word-spacing: 5px;
}
.nav {
  background-color: white;
  width: 100%;
  border-top: solid 1px #999;
  border-bottom: solid 2px #333333;
  font-weight: bold;
  font-size: 15px;
  font-weight: normal;
}

.nav, .nav ul {
  padding: 0;
  margin: 0;
  list-style: none;
  line-height: 2.5;
  /* font-size: 13px; */
  z-index: 100;
}

.nav li {
    display: inline;
    margin: 0 10px;
}

.nav li a {
  background-color: white;
  text-decoration: none;
  padding-right: 5px;
  padding-left: 5px;
}

希望这有帮助。

您可以尝试添加
单词间距:5px

.nav {
  background-color: white;
  width: 100%;
  min-height: 29px;
  line-height: 26px;
  border-top: solid 1px #999;
  border-bottom: solid 2px #333333;
  font-weight: bold;
  position: relative;
  border: none;
  font-size: 15px;
  font-weight: normal;
  word-spacing: 5px;
}
.nav {
  background-color: white;
  width: 100%;
  border-top: solid 1px #999;
  border-bottom: solid 2px #333333;
  font-weight: bold;
  font-size: 15px;
  font-weight: normal;
}

.nav, .nav ul {
  padding: 0;
  margin: 0;
  list-style: none;
  line-height: 2.5;
  /* font-size: 13px; */
  z-index: 100;
}

.nav li {
    display: inline;
    margin: 0 10px;
}

.nav li a {
  background-color: white;
  text-decoration: none;
  padding-right: 5px;
  padding-left: 5px;
}

希望这有帮助。

您可以尝试添加
单词间距:5px

.nav {
  background-color: white;
  width: 100%;
  min-height: 29px;
  line-height: 26px;
  border-top: solid 1px #999;
  border-bottom: solid 2px #333333;
  font-weight: bold;
  position: relative;
  border: none;
  font-size: 15px;
  font-weight: normal;
  word-spacing: 5px;
}
.nav {
  background-color: white;
  width: 100%;
  border-top: solid 1px #999;
  border-bottom: solid 2px #333333;
  font-weight: bold;
  font-size: 15px;
  font-weight: normal;
}

.nav, .nav ul {
  padding: 0;
  margin: 0;
  list-style: none;
  line-height: 2.5;
  /* font-size: 13px; */
  z-index: 100;
}

.nav li {
    display: inline;
    margin: 0 10px;
}

.nav li a {
  background-color: white;
  text-decoration: none;
  padding-right: 5px;
  padding-left: 5px;
}
希望这有帮助

.nav {
  background-color: white;
  width: 100%;
  border-top: solid 1px #999;
  border-bottom: solid 2px #333333;
  font-weight: bold;
  font-size: 15px;
  font-weight: normal;
}

.nav, .nav ul {
  padding: 0;
  margin: 0;
  list-style: none;
  line-height: 2.5;
  /* font-size: 13px; */
  z-index: 100;
}

.nav li {
    display: inline;
    margin: 0 10px;
}

.nav li a {
  background-color: white;
  text-decoration: none;
  padding-right: 5px;
  padding-left: 5px;
}
根据需要添加样式重置。 编辑:仅在必要时使用位置和z索引

根据需要添加样式重置。 编辑:仅在必要时使用位置和z索引

根据需要添加样式重置。 编辑:仅在必要时使用位置和z索引

根据需要添加样式重置。 编辑:仅在必要时使用位置和z索引


删除
元素上的宽度:

并加上:

.nav li {margin-right: 10px /* or whatever margin you want */}
.nav li:last-child {margin-right: 0}

删除
元素上的宽度:

并加上:

.nav li {margin-right: 10px /* or whatever margin you want */}
.nav li:last-child {margin-right: 0}

删除
元素上的宽度:

并加上:

.nav li {margin-right: 10px /* or whatever margin you want */}
.nav li:last-child {margin-right: 0}

删除
元素上的宽度:

并加上:

.nav li {margin-right: 10px /* or whatever margin you want */}
.nav li:last-child {margin-right: 0}

  • 元素之间没有边距:您可以删除锚点上的宽度
  • 元素之间没有边距:您可以删除锚点上的宽度
  • 元素之间没有边距:您可以删除锚点上的宽度
  • 元素之间没有边距:非常感谢@thePav,您可以删除锚上的宽度!非常感谢@thePav!非常感谢@thePav!非常感谢@thePav!非常感谢您的时间@rkamath它有帮助,但我找到了如下所示的更容易的选项,再次感谢。非常感谢您的时间@rkamath它有帮助,但我找到了如下所示的更容易的选项,再次感谢。非常感谢您的时间@rkamath它有帮助,但我找到了如下所示的更容易的选项,再次感谢。非常感谢您的时间@rkamath,这很有帮助,但我找到了如下所示的更简单的选择,再次感谢。