我有 CSS 代码来显示标签,在我的 localhost
(Node.Js 应用程序)上一切看起来都很好,但是一旦我将它上传到服务器上,就会出现一条奇怪的线,而且两个版本都使用相同的 git 存储库。
你知道问题出在哪里吗?
这是HTML代码
<ul class="tags">
<li><a href="#">tag 1</a></li>
<li><a href="#">tag 2</a></li>
<div class="tagsend"></div>
</ul>
和CSS
.tags{
margin:0;
padding:0;
list-style:none;
}
.tags li, .tags a{
float:right;
height:24px;
line-height:24px;
position:relative;
font-size:11px;
}
.tagsend {
clear:both;
}
.tags a{
margin-left:20px;
padding:0 10px 0 12px;
background:#0089e0;
color:#fff;
text-decoration:none;
-moz-border-radius-bottomright:4px;
-webkit-border-bottom-right-radius:4px;
border-bottom-right-radius:4px;
-moz-border-radius-topright:4px;
-webkit-border-top-right-radius:4px;
border-top-right-radius:4px;
}
.tags a:before{
content:"";
float:left;
position:absolute;
top:0;
left:-12px;
width:0;
height:0;
border-color:transparent #0089e0 transparent transparent;
border-style:solid;
border-width:12px 12px 12px 0;
}
.tags a:after{
content:"";
position:absolute;
top:10px;
left:0;
float:left;
width:4px;
height:4px;
-moz-border-radius:2px;
-webkit-border-radius:2px;
border-radius:2px;
background:#fff;
-moz-box-shadow:-1px -1px 2px #004977;
-webkit-box-shadow:-1px -1px 2px #004977;
box-shadow:-1px -1px 2px #004977;
}
.tags a.notfound{
background: #666666;
opacity: 0.2;
}
.tags a.notfound:before{
border-color:transparent #666666 transparent transparent;
}
.tags a:hover{
background:#666;
opacity: 0.2;
}
.tags a:hover:before{
border-color:transparent #555 transparent transparent;
}
最佳答案
视觉效果很可能与将 Chrome 缩小到 100% 以外的级别有关(感谢@ArberBraja 的提示并实际发现了这一点)。我在 Chrome 中使用默认的 100% 缩放级别时完全没有遇到这个问题,但是当我缩小到 90% 时我遇到了这个问题:
如果这仍然是一个问题(即:您需要在所有缩放级别都支持“像素完美”渲染),您将需要重新设计添加标签倾斜尖端的方式,使其不那么聪明:
.tags a:before{
content:"";
float:left;
position:absolute;
top:0;
left:-12px; // This is the problem
width:0;
height:0;
border-color:transparent #0089e0 transparent transparent;
border-style:solid;
border-width:12px 12px 12px 0;
}
由于您将边框向左偏移了 12 个像素,Chrome 浏览器会将此数字缩小到产生像素不完美结果的值。您可能需要为整个标签使用纯色背景图像,以便正确支持所有缩放级别。
关于html - 用于在圆 Angular 框中显示标签的 CSS 代码一旦上传到服务器就会中断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26852557/