CSS三角形在缩放时会出现白色空隙

4
我使用了CSS三角形的方法来创建进度步骤:http://css-tricks.com/snippets/css/css-triangle/ 问题是,当缩放浏览器(例如在chrome中缩放到90%和110%)时,三角形与它所连接的元素之间会有空白。您可以在这里查看示例:http://plnkr.co/edit/cPsvVIlKX2gQseONTixf?p=preview
.steps {
  list-style-type: none;
  padding: 0;
}
.steps li {
  display: inline-block;
  margin-bottom: 3px;
}
.steps li a, .steps li p {
  background: #e5f4fd;
  padding: 8px 20px;
  color: #0077bf;
  display: block;
  font-size: 14px;
  font-weight: bold;
  position: relative;
  text-indent: 12px;
}
.steps li a:hover, .steps li p:hover {
  text-decoration: none;
}
.steps li a:before, .steps li p:before {
  border-bottom: 18px solid transparent;
  border-left: 12px solid #fff;
  border-top: 18px solid transparent;
  content: "";
  height: 0;
  position: absolute;
  left: 0;
  top: 50%;
  width: 0;
  margin-top: -18px;
}
.steps li a:after, .steps li p:after {
  border-bottom: 18px solid transparent;
  border-left: 12px solid #e5f4fd;
  border-top: 18px solid transparent;
  content: "";
  height: 0;
  position: absolute;
  right: -12px;
  top: 50%;
  width: 0;
  margin-top: -18px;
  z-index: 1;
}
.steps li.active a, .steps li.active p {
  background: #0077bf;
  color: #fff;
}
.steps li.active a:after, .steps li.active p:after {
  border-left: 12px solid #0077bf;
}
.steps li.undone a, .steps li.undone p {
  background: #eee;
  color: #333;
}
.steps li.undone a:after, .steps li.undone p:after {
  border-left: 12px solid #eee;
}
.steps li.undone p {
  color: #aaa;
}

示例:

这里输入图片描述

有什么解决方法吗?

1个回答

3
针对这些定位问题,通常不使用设置像素值,而是让自然值为你工作会更加有用。
所以...
将此改为:
.steps li a:after, .steps li p:after {
  border-bottom: 18px solid transparent;
  border-left: 12px solid #e5f4fd;
  border-top: 18px solid transparent;
  content: "";
  height: 0;
  position: absolute;
  /*right: -12px;*/ /* remove this */
  left:100%; /* add this */
  top: 50%;
  width: 0;
  margin-top: -18px;
  z-index: 1;
}

Demo


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接