我想在导航中的“ Li”元素之间设置相等的边距。
现在之间
左边距和右边距如下图所示。

Here is a fiddle link



这是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;
}

最佳答案

删除<a>元素上的宽度:



并添加以下内容:

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

07-25 23:31
查看更多