html - 不同系统上的 css3 箭头

标签 html css

我做了两个箭头,在 MacOSX 上编码,我无意中发现箭头在 Windows 上看起来不太好。是因为分辨率还是代码不正确?

https://jsfiddle.net/m7ynysdp/

<div class="arrow a1"></div>
<div class="arrow a2"></div>

.arrow {
    height: 0;
    border-bottom: 2px solid;
    border-width: 2px;
    position: relative;
    color: #000;
}

.a1 {
    position: absolute;
    top: 51%;
    left: 76%;
    transform: translate(-51%, -76%);
    width: 22vw;
    transform: rotate(-156deg);
    transform-origin: 0;
    border-bottom: 2px solid;
}

.a2 {
    position: absolute;
    top: 53%;
    left: 65%;
    transform: translate(-53%, -65%);
    width: 6.5vw;
    transform: rotate(-111deg);
    transform-origin: 0;
    border-bottom: 2px solid;
    cursor: pointer;
    transition: color .3s;
}

.arrow::before {
    position: absolute;
    top: -13px;
    right: -3px;
    content: '>';
    display: block;
    font-size: 1.4rem;
}

第一个在 mac 上,第二个在 Windows 上,都是 Chrome 最新版本

enter image description here

enter image description here

最佳答案

由于某种原因,它偏离了一个像素。将位置更改为 -> top: -12px; 并添加 font-weight: bold; 属性似乎可以解决此问题。

.arrow::before {
    position: absolute;
    top: -12px;
    right: -3px;
    content: '>';
    display: block;
    font-size: 1.4rem;
    font-weight: bold;
}

https://jsfiddle.net/oqfes3sk/

也许您可以在检测到用户代理后为 Mac 和 PC 添加单独的代码:

jQuery(document).ready(function(){
 if(navigator.userAgent.indexOf('Mac') > 0){
  jQuery('body').addClass('mac');
 } else {
  jQuery("body").addClass("pc");
 }
});

然后:

.mac .arrow:before {

  ...
  top: -13px;

}

.pc .arrow:before {

  ...
  top: -12px;
  font-weight: bold;

}

关于html - 不同系统上的 css3 箭头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42547406/

相关文章:

javascript - 如何从另一个 HTML 页面调用表格

php - 在 PHP 中寻找流氓 &lt;!---->

javascript - 透明 src 以便背景显示

jquery - 尝试使用 jQuery 控制 css3 转换命令来旋转 div 元素

javascript - 显示错误时如何为边框着色?

javascript - 如何制作分数进度条 HTML/CSS/JS

javascript - 如何修复此 $scope 以在 HTML 中显示

html - 是否可以缩小 float 元素旁边图像的宽度(响应式)?

javascript - 寻找基于 JS 的 CSS 自动补全

html - IE6 中的 css li 菜单动态线宽