Giter Site home page Giter Site logo

关于Retina屏幕下1px的问题 about elf HOT 2 CLOSED

o2team avatar o2team commented on July 30, 2024
关于Retina屏幕下1px的问题

from elf.

Comments (2)

booxood avatar booxood commented on July 30, 2024

模板中有提供 mixin

/**
 * 1像素边框
 * @param  {string} $position [边框位置,取值:top, bottom, left, right, full]
 * @param  {string} $borderColor [边框颜色]
 * @param  {number} $raidus [圆角]
 *
 * 例子:
 *   @include border(top, #ddd);
 *   @include border(full, #ddd, 2px);
 */
@mixin border($position: full, $borderColor: #ddd, $radius: 0) {
  content: '';
  position: absolute;
  z-index: 1;
  pointer-events: none;
  background-color: $borderColor;

  @if $position == top {
    height: 1px;
    left: 0;
    right: 0;
    top: 0;

    @media only screen and (-webkit-min-device-pixel-ratio:2) {
      & {
        transform: scaleY(0.5);
        transform-origin: 50% 0%;
      }
    }
  } @else if $position == bottom {
    height: 1px;
    left: 0;
    right: 0;
    bottom: 0;

    @media only screen and (-webkit-min-device-pixel-ratio:2) {
      & {
        transform: scaleY(0.5);
        transform-origin: 50% 100%;
      }
    }
  } @else if $position == left {
    width: 1px;
    top: 0;
    bottom: 0;
    left: 0;

    @media only screen and (-webkit-min-device-pixel-ratio:2) {
      & {
        transform: scaleX(0.5);
        transform-origin: 0% 50%;
      }
    }
  } @else if $position == right {
    width: 1px;
    top: 0;
    bottom: 0;
    right: 0;

    @media only screen and (-webkit-min-device-pixel-ratio:2) {
      & {
        transform: scaleX(0.5);
        transform-origin: 100% 50%;
      }
    }
  } @else if $position == full {
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    background: none;
    border: 1px solid #ddd;
    border-color: $borderColor;

    @if $radius != 0 {
      border-radius: $radius;
    }

    @media only screen and (-webkit-min-device-pixel-ratio:2) {
      & {
        right: -100%;
        bottom: -100%;
        transform: scale(0.5);
        transform-origin: 0% 0%;

        $radiusx2: null;
        @each $i in $radius {
          $radiusx2: append($radiusx2, $i * 2);
        }

        @if $radius != 0 {
          border-radius: $radiusx2;
        }
      }
    }
  }
}

from elf.

booxood avatar booxood commented on July 30, 2024

没问题先关闭了

from elf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.