css 来自水平ul列表的神秘左填充

k97glaaz  于 2024-01-09  发布在  其他
关注(0)|答案(2)|浏览(129)

我做了一个水平无序列表,除了有一些左填充外,效果很好。我希望UL与它的容器齐平,没有任何填充。
我试过margin-left:0,但没有成功。
有人能看到或想到一种方法,让我的标记是齐平左?

ul.speakerclass > li {
    display: inline-block;
    /* You can also add some margins here to make it look prettier */
    width:180px;
    zoom:1;
    *display:inline;
    /* this fix is needed for IE7- */
}

.speakercard {
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
  max-width: 180px;
  margin: auto;
  text-align: center;
  padding-top: 14px;
}

button.speakerclass {
  border: none;
  outline: 0;
  display: inline-block;
  padding: 10px;
  color: white;
  background-color: #393939;
  text-align: center;
  cursor: pointer;
  width: 100%;
}

a.speakerclass {
  text-decoration: none;
  color: black;
}

button.speakerclass:hover, a:hover {
  opacity: 0.7;
}

.speaker-box {
  width: 100px;
  height: 100px;
  position: relative;
  overflow: hidden;
  border-radius: 50%;
  border:1px solid #ccc;
  margin-left: auto;
  margin-right: auto;
}

.speaker-pic {
  display: inline;
  margin: 0 auto;
  height: 100%;
  width: auto;
}

个字符
谢谢你的帮助

oxiaedzo

oxiaedzo1#

加上这个:

ul.speakerclass {
    padding: 0;
}

字符串

lnxxn5zx

lnxxn5zx2#

ul.speakerclass容器设置padding-left: 0删除了空间。
根据W3C标准,<ul>元素默认有一个padding-inline-start: 40px。这说明了40px的左填充。

ul.speakerclass {
  padding-left: 0;
}

ul.speakerclass > li {
    display: inline-block;
    /* You can also add some margins here to make it look prettier */
    width:180px;
    zoom:1;
    *display:inline;
    /* this fix is needed for IE7- */
}

.speakercard {
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
  max-width: 180px;
  margin: auto;
  text-align: center;
  padding-top: 14px;
}

button.speakerclass {
  border: none;
  outline: 0;
  display: inline-block;
  padding: 10px;
  color: white;
  background-color: #393939;
  text-align: center;
  cursor: pointer;
  width: 100%;
}

a.speakerclass {
  text-decoration: none;
  color: black;
}

button.speakerclass:hover, a:hover {
  opacity: 0.7;
}

.speaker-box {
  width: 100px;
  height: 100px;
  position: relative;
  overflow: hidden;
  border-radius: 50%;
  border:1px solid #ccc;
  margin-left: auto;
  margin-right: auto;
}

.speaker-pic {
  display: inline;
  margin: 0 auto;
  height: 100%;
  width: auto;
}

个字符

相关问题