【问题标题】:Incorrect border rendering when using css transform in Firefox在 Firefox 中使用 css 转换时不正确的边框渲染
【发布时间】:2016-03-06 12:30:50
【问题描述】:

我有一个像这样的简单 CSS 箭头:

.arrow-brown {
    height: 18px;
    width: 18px;
    border-top: 6px solid #39170b;
    border-right: 6px solid #39170b;
    -moz-transform: rotate(-45deg);
    -ms-transform: rotate(-45deg);
    -webkit-transform: rotate(-45deg);
    transform: rotate(-45deg);
}

在 Firefox 中,边框未正确呈现,两条细白线出现在边框宽度上。有什么办法可以摆脱它们吗??

这是渲染的图片: http://i.imgur.com/TmoAPv6.png

这是小提琴: https://jsfiddle.net/w2s9gp8w/

【问题讨论】:

    标签: html css firefox


    【解决方案1】:

    这对我有用:

    transform-style: preserve-3d;
    

    【讨论】:

      【解决方案2】:

      我在 Firefox 中遇到了类似的问题,使用 transform(具体来说是scale)时无法正确呈现边框。添加一个非常小的border-radius 为我解决了这个问题。

      border-radius: 0.01px;
      

      【讨论】:

        【解决方案3】:

        您可以尝试通过box-shadowlinear-gradient 绘制边框

        div {
          margin: 20px;
          float: left;
          -moz-transform: rotate(-45deg);
          -ms-transform: rotate(-45deg);
          -webkit-transform: rotate(-45deg);
          transform: rotate(-45deg);
        }
        .box-shadow {
          height: 68px;
          width: 68px;
          box-shadow: inset -18px 18px #39170b;
        }
        .arrow-brown {
          height: 50px;
          width: 50px;
          border-top: 18px solid #39170b;
          border-right: 18px solid #39170b;
        }
        .gradient {
          height: 68px;
          width: 68px;
          background: linear-gradient(to left, #39170b, #39170b) top right no-repeat, linear-gradient(to top, #39170b, #39170b) top left no-repeat;
          background-size: 18px 100%, 100% 18px;
        }
        th {
          color:red;
          }
        th:last-of-type {
          color:#54A719;
          }
        <table>
          <caption>Tests on rotated shapes</caption>
          <thead>
            <tr>
              <th>border</th>
              <th>box-shadow</th>
              <th>linear-gradient</th>
            </tr>
            <thead>
              <tbody>
                <tr>
                  <td>
                    <div class="arrow-brown"></div>
                  </td>
                  <td>
                    <div class="box-shadow"></div>
                  </td>
                  <td>
                    <div class="gradient"></div>
                  </td>
                </tr>
              </tbody>
        </table>

        http://codepen.io/gcyrillus/pen/GZoKRj

        【讨论】:

          猜你喜欢
          • 2022-06-29
          • 2011-02-19
          • 1970-01-01
          • 2013-05-02
          • 2022-11-15
          • 2019-10-16
          • 1970-01-01
          • 1970-01-01
          • 2017-10-10
          相关资源
          最近更新 更多